home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 41.zip / BS1 part 41 / Abacus diskdrives IO.adf / Assembler / DeepCopy.s < prev    next >
Text File  |  1978-06-28  |  130KB  |  4,289 lines

  1. ;The Listing of the Copy Program
  2. key            = $BFEC01
  3. Cont           = $BFEE01
  4. IntCon         = $BFED01
  5. MaxWait        = $4000
  6. MinWait        = $1000
  7. ;
  8. ;------- graphics.library ------
  9. ;
  10. Textout              = -30 - 30
  11. InitRastPort         = -30 -168
  12. Movee                = -30 -210
  13. Draw                 = -30 -216
  14. RectFill             = -30 -276
  15. SetAPen              = -30 -312
  16. InitBitMap           = -30 -360
  17. ;
  18. ;--------- exec.library --------
  19. ;
  20. ExecBase             =        4
  21. ;
  22. AllocMem             = -30 -168
  23. AvailMem             = -216
  24. FreeMem              = -30 -180
  25. OldOpenLibrary       = -30 -378
  26. CloseLibrary         = -30 -384
  27. FindName             = -276
  28. ;
  29. MEMF_Chip            = $02
  30. MEMF_Fast            = $04
  31. MEMF_Largest         = $20000
  32.  
  33. DevList              = 350
  34. Port                 = 36       ;Drive 0
  35. IDNestCnt      = 294
  36.  
  37. ;
  38. ;-------------------------------
  39. ;
  40. floppy_size = floppyend - floppy
  41.  
  42. floppy_s       = floppy_size/6-1
  43.  
  44. ON             = 1
  45. OFF            = 0
  46.  
  47. ;Error-Flag Values
  48.  
  49. NoError        = $0000
  50. NoSync         = $0001
  51. LengthUnequal  = $0002
  52. LengthUnequal2 = $0003
  53. NoDisk         = $0004
  54. ReadError      = $0005
  55. VerifyError    = $0006
  56. DiskProtect    = $0007
  57. NotProtect     = $0008
  58. Escape         = $0009
  59.  
  60. CopyAttempt1  = 3                  ;Attempts on illegal Data 
  61. CopyAttempt2  = 3                  ;Attempts on NoSync
  62.  
  63. ;Load options 
  64.  
  65. WithoutSync     = $0000
  66. WithSync        = $ffff
  67.  
  68. ;Write options
  69.  
  70. NoIndex        = $0000
  71. IndexOk        = $ffff
  72.  
  73. ;Size of memory used
  74.  
  75. SortBlockNum  = $40   ;Number of blocks,
  76.                       ;whose length is sorted
  77. Bytesread      = $3600
  78. BSize          = 2*Bytesread
  79. req            = 2        ;Chip-Memory
  80. CIAA           = $BFE000
  81.  
  82. GapLengthF    = $500 ;Length of Gap for FastCopy
  83. NumReadsF      = 5   ;Number of Read attempts for Readerror (Fast)
  84.  
  85. ;Values for Cruncher
  86.  
  87. ShrtNull       = $80
  88. MiddleNull     = $20
  89. LongNull       = $08
  90. ShrtNorm       = $40
  91. MiddleNorm     = $10
  92. LongNorm       = $04
  93. ShrtNone       = $c0
  94. MiddleNone     = $30
  95. LongNone       = $02
  96. EmptyBlock     = $01
  97.  
  98.  
  99.                lea DevName,a1
  100.                move.l $4,a6
  101.                lea DevList(a6),a0
  102.                jsr FindName(a6)
  103.                move.l d0,a0
  104.                beq Ende
  105.                lea Port(a0),a0
  106.                clr.w d0
  107. \An2:          tst.l (a0)+
  108.                beq \An1
  109.                bset d0,Drives
  110. \An1:          addq.w #1,d0
  111.                cmp.w #4,d0
  112.                bne.s \An2
  113.         move.l ExecBase,a6
  114.         lea    gfxname,a1
  115.         jsr    OldOpenLibrary(a6)
  116.         move.l d0,gfxbase
  117.         beq    no_gfxbase
  118.  
  119.         move.l #$2800,d0
  120.         move.l #$10002,d1
  121.         jsr    AllocMem(a6)
  122.         move.l d0,bit_adress
  123.         beq    no_bitmap
  124.  
  125.         move.l #copsize+2,d0
  126.         move.l #$10002,d1
  127.         jsr    AllocMem(a6)
  128.         move.l d0,cop_adress
  129.         beq    no_copper
  130.                MOVE.L #BSize,D0
  131.                MOVE.L #req,D1
  132.                JSR AllocMem(A6)
  133.                TST.L D0
  134.                BEQ no_DPuffer
  135.                MOVE.L D0,TrackBuffer1
  136.                addq.l #6,TrackBuffer1
  137.                add.l #Bytesread-6,d0
  138.                move.l D0,TrackBuffer2
  139.                bsr GetMemory           ;Memory for Cruncher
  140.  
  141.                bra beg
  142. copy_start:    MOVE.L $4,A6
  143.                MOVE.B #$FF,$BFD300
  144.                move.w #$0020,$dff09a
  145.                JSR Disable
  146.  
  147.                MOVE.W #$8210,$DF096      ;set DMA-Reg. 
  148.  
  149.                clr.w FreeFlagCh
  150.                clr.w FreeFlagFa
  151.  
  152.                bsr HeadMov       ;set Heads to Null and set Motorbits 
  153.                bsr Start_End     ;determine copy area 
  154.                cmp.b #ON,dc1     ;Deepcopy 1
  155.                beq \ME7
  156.                cmp.b #ON,dc2
  157.                bne \ME5
  158. \ME7:          move.b SD,d0              ;one Drive-Copy?
  159.                cmp.b DD,d0
  160.                beq \ME6                  ;yes 
  161.                bsr SwitchS
  162. \ME5:          bsr TestProtect
  163.                tst.l d0
  164.                bmi \ME4
  165.                bsr protect_source
  166.                tst.l d0
  167.                bmi \ME3                  ;Escape
  168.                bra \ME5
  169. \ME4:
  170.                cmp.b #ON,fa              ;Fastcopy on?
  171.                bne \ME1
  172.                bsr FastCopy
  173.                bra \ME3
  174. \ME1:          cmp.b #ON,dc1             ;Deepcopy1 on?
  175.                bne \ME2
  176.                bsr DeepCopy
  177.                bra \ME3
  178. \ME2:          cmp.b #ON,dc2             ;Deepcopy2 on?
  179.                bne \ME3
  180. \ME6:          bsr DeepCopy
  181. \ME3:
  182.                bsr SwitchS
  183.                bsr MotorOff
  184.                bsr SwitchD
  185.                bsr MotorOff
  186.  
  187.                move.w #$0600,$dff09e
  188.                move.w #$8100,$dff09e     ;restore Bits
  189. \Error:       bsr Enable
  190.         move.w #$8020,$dff09a
  191. Ende:          rts
  192.  
  193. TextoutL:      move.w StartTrack,d0
  194.                lsr.w #1,d0
  195.                move.b d0,Cylinder
  196.                bsr reading_cyl
  197.                rts
  198. TextoutS:      move.w StartTrack,d0
  199.                lsr.w #1,d0
  200.                move.b d0,Cylinder
  201.                bsr writing_cyl
  202.                rts
  203. ;output Read-Error 
  204. RError:        move.w StartTrack,d0
  205.                move.b #1,side
  206.                btst #0,d0
  207.                bne \RE1
  208.                clr.b side
  209. \RE1:          lsr.w #1,d0
  210.                move.b d0,Cylinder
  211.                bsr read_error
  212.                rts
  213. ;output Write-Error 
  214. WError:        move.w StartTrack,d0
  215.                move.b #1,side
  216.                btst #0,d0
  217.                bne \RE1
  218.                clr.b side
  219. \RE1:          lsr.w #1,d0
  220.                move.b d0,Cylinder
  221.                bsr write_error
  222.                rts
  223.  
  224. FastCopy:
  225.                bsr GapCreate
  226.                move.b DD,d0
  227.                cmp.b SD,d0
  228.                beq \FC1
  229.                bra FastCopyML            ;for several Drives
  230. \FC1:          bra FastCopyEL            ;for one Drive
  231.  
  232. ;FastCopy for several Drives
  233. FastCopyML:
  234.                bsr SwitchD
  235. \FC5:          bsr TestProtect
  236.                tst.l d0
  237.                bpl \FC1
  238.                bsr protect_Destination
  239.                tst.l d0
  240.                bmi \Error                ;Escape
  241.                bra \FC5
  242. \FC1:          bsr TextoutL
  243.                bsr TrackLSF              ;load Track from Source 
  244.                cmp.w #NoDisk,ErrorFlag
  245.                beq \Error
  246.                bsr SwitchD
  247.                move.w StartTrack,d0
  248.                bsr HeadPos
  249.                bsr TextoutS
  250.                bsr TrackFastWrite
  251.                cmp.w #NoDisk,ErrorFlag
  252.                beq \Error
  253.                cmp.w #DiskProtect,ErrorFlag
  254.                bne \FC3
  255.                bsr protect_destination
  256.                bra \Error
  257. \FC3:          cmp.b #ON,vd              ;Verify ON ?
  258.                bne \FC2                  ;branch if not on 
  259.                bsr TrackFVerify
  260.                cmp.w #NoDisk,ErrorFlag
  261.                beq \Error
  262.                cmp.w #VerifyError,ErrorFlag
  263.                bne \FC2
  264.                bsr WError
  265.                bsr compare_drives
  266. \FC2:          add.w #1,StartTrack
  267.                move.w StartTrack,d0
  268.                cmp.w EndTrack,d0
  269.                bls \FC1
  270. \Error        rts
  271.  
  272. ;FastCopy for one Drive
  273.  
  274. FastCopyEL:
  275.                clr.b ShrtByte            ;ShortByte for Chruncher = 0
  276.                move.w #$1600,Length
  277.                bsr NextMemory            ;assign memory
  278. \FCEL1:        bsr TestProtect
  279.                tst.l d0
  280.                bmi \FCEL3
  281.                bsr protect_Source
  282.                tst.l d0
  283.                bmi \FCEL2                ;Escape activated 
  284.                bra \FCEL1
  285. \FCEL3:        bsr FCopy1DL              ;read in memory
  286.                tst.l d0
  287.                bmi \FCEL2
  288.                move.l WriteAddrs,a5
  289.                add.l #GapLengthF,a5
  290. \FCEL7:        move.w TNumBufferA,StartTrack
  291.                bsr insert_destination
  292.                tst.l d0
  293.                bmi \FCEL2                ;Escape
  294. \FCEL5:        bsr TestProtect
  295.                tst.l d0
  296.                bpl \FCEL6
  297.                bsr protect_Destination
  298.                tst.l d0
  299.                bmi \FCEL2                ;Escape activated
  300.                bra \FCEL5
  301. \FCEL6:        bsr FCopy1DS              ;Write Tracks
  302.                tst.l d0
  303.                bmi \FCEL2
  304.                cmp.b #ON,ws              ;write repeatedly ?
  305.                bne \FCEL8                ;no 
  306.                bsr write_b_again
  307.                cmp.w #Escape,ErrorFlag
  308.                beq \FCEL2
  309.                tst.l d0
  310.                bpl \FCEL7                ; write again 
  311. \FCEL8:        move.w StartTrack,TNumBufferA
  312.                move.w TNumBufferE,d0
  313.                cmp.w EndTrack,d0
  314.                bcc \FCEL2
  315.                bsr insert_source
  316.                tst.l d0
  317.                bmi \FCEL2                ;Escape
  318.                bra \FCEL1
  319. \FCEL2:        rts
  320.  
  321. FCopy1DL:
  322. \FCD1:         bsr TrackLSF              ;load Track from Source 
  323.                cmp.w #NoDisk,ErrorFlag
  324.                beq \Error
  325.                move.l TrackBuffer2,a0    ;pass Pointer 
  326.                bsr Packe                 ;crunch Track 
  327.                tst.l d0
  328.                bmi \FCD2                 ;memory full
  329.                bsr TextoutL              ;output Text 
  330.                add.w #1,StartTrack
  331.                move.w StartTrack,d0
  332.                cmp.w EndTrack,d0
  333.                bls \FCD1
  334. \FCD2:         subq.w #1,StartTrack
  335.                clr.l d0
  336.                move.w StartTrack,TNumBufferE       ;Last Track
  337.                rts
  338. \Error:       move.l #-1,d0
  339.                rts
  340.  
  341. ;Copy portion for writing with one Drive
  342. FCopy1DS:
  343.                move.w StartTrack,d0      ;first Track read
  344. \FDS1:         bsr HeadPos
  345.                bsr TextoutS
  346.                move.l TrackBuffer2,a0    ;Buffer for Track (Target)
  347.                bsr EntPacke              ;Track in regular size again
  348.                move.l a5,a1              ;Target (TrackBuffer1 + Gap)
  349.                move.l TrackBuffer2,a0    ;Source
  350.                move.w StartTrack,d0      ;Track to be read
  351.                bsr CodeTrack             ;code Track 
  352.                move.w #00,FirstBlockSp   ;first Block = Null
  353.                bsr TrackFastWrite
  354.                cmp.w #NoDisk,ErrorFlag
  355.                beq \Error
  356.                cmp.w #DiskProtect,ErrorFlag
  357.                bne \FDS3
  358.                bsr protect_destination
  359.                bra \Error
  360. \FDS3:         cmp.b #ON,vd              ;Verify ON ?
  361.                bne \FDS2                 ;branch if not on
  362.                bsr TrackFVerify
  363.                cmp.w #NoDisk,ErrorFlag
  364.                beq \Error
  365.                cmp.w #VerifyError,ErrorFlag
  366.                bne \FDS2
  367.                bsr WError
  368. \FDS2:         bsr Get_Key               ;Escape activated?
  369.                cmp.b #$45,d0
  370.                bne \FCS4                 ;no, continue 
  371.                move.w #Escape,ErrorFlag
  372.                bra \Error
  373. \FCS4:         addq.w #1,StartTrack
  374.                move.w StartTrack,d0
  375.                cmp.w TNumBufferE,d0
  376.                bls \FDS1
  377.                clr.l d0
  378.                clr.w FreeFlagCh          ;Chip-Mem is available again 
  379.                clr.w FreeFlagFa          ;Fast-Memomory is available again
  380.                rts
  381. \Error:       move.l #-1,d0
  382.                rts
  383.  
  384. ;crunch Track and store 
  385. ;>= A0 Pointer to TrackBuffer
  386. Packe:                                   ;Pointer to Track
  387.                move.l a2,-(a7)
  388.                move.l a0,a2
  389. \PA2:          lea TrackPointer,a0       ;Pointer to Track-Table
  390.                clr.l d0
  391.                move.w StartTrack,d0      ;Track-Number
  392.                lsl.w #2,d0
  393.                adda.l d0,a0              ;Pointer to Memory pointer
  394.                move.l MemoryBeg,(a0)     ;store Pointer to Track
  395.                move.l MemoryBeg,a1
  396.                move.l a2,a0
  397.                bsr Crunch
  398.                tst.l d0
  399.                bpl \PA1                  ;Ok, continue 
  400.                bsr NextMemory            ;get new Mempory
  401.                tst.l d0
  402.                bpl \PA2                  ;Ok, Memory obtained
  403. \PA1:          move.l (a7)+,a2
  404.                rts
  405.  
  406. ;get Track from memory
  407. ;>= A0 = Pointer to Target for Track
  408. EntPacke:
  409.                move.l a0,a1
  410.                lea TrackPointer,a0       ;Pointer to Track-Table 
  411.                clr.l d0
  412.                move.w StartTrack,d0      ;Track-Number
  413.                lsl.w #2,d0
  414.                adda.l d0,a0              ;Pointer to memory pointer
  415.                move.l (a0),a0            ;get Pointer to Track
  416.                bsr DeCrunch
  417.                rts
  418.  
  419. GetMemory:
  420.                move.l a6,-(a7)
  421.                move.l #MEMF_Chip,d1
  422.                or.l #MEMF_Largest,d1
  423.                move.l ExecBase,a6
  424.                jsr AvailMem(a6)
  425.                move.l d0,LengthChip
  426.                bne \HS1
  427.                clr.l MemoryChip          ;no Chip available
  428.                bra \HS2                  ;get Fast-Memory 
  429. \HS1:          jsr AllocMem(a6)
  430.                move.l d0,MemoryChip
  431. \HS2:          move.l #MEMF_Fast,d1
  432.                or.l #MEMF_Largest,d1
  433.                jsr AvailMem(a6)
  434.                move.l d0,LenghtFast
  435.                bne \HS3                  ;ok
  436.                clr.l MemoryFast
  437.                bra \HS4                  ;no fast memory available 
  438. \HS3:          jsr AllocMem(a6)
  439.                move.l d0,MemoryFast
  440. \HS4:          move.l (a7)+,a6
  441.                clr.w FreeFlagCh          ;memory is free
  442.                clr.w FreeFlagFa
  443.                rts
  444.  
  445. ;get next memory block
  446. NextMemory:
  447.                tst.w FreeFlagCh          ;Chip not available 
  448.                bpl \NS1                  ;Yes, is free 
  449. \NS3:          tst.w FreeFlagFa          ;Fast memory still available 
  450.                bpl \NS4                  ;Yes, is free 
  451. \NS5:          move.l #-1,d0             ;no memory free 
  452.                bra \NS2
  453. \NS4:          move.l MemoryFast,d0
  454.                beq \NS5                  ;no Fast memory free 
  455.                move.l LenghtFast,d1
  456.                move.w #$ffff,FreeFlagFa  ;Fast memory occupied 
  457.                bra \NS6
  458. \NS1:          move.l MemoryChip,d0
  459.                beq \NS3                  ;no Chip free
  460.                move.l LengthChip,d1
  461.                move.w #$ffff,FreeFlagCh  ;occupy Chip 
  462. \NS6:          move.l d0,MemoryBeg
  463.                move.l d1,MemoryLength
  464.                clr.l d0
  465. \NS2:          rts
  466.  
  467. ;load Track (Fastcopy)
  468. ;>= StartTrack = Track to be loaded 
  469. ;=> SBytes = Number of Bytes to be written 
  470. ;=> WriteAddrs = Address from which writing starts
  471.  
  472. TrackLSF:
  473.                movem.l d2/a2,-(a7)
  474.                bsr SwitchS
  475.                move.l TrackBuffer1,a5
  476.                move.l a5,WriteAddrs
  477.                add.l #GapLengthF,a5
  478.                move.l TrackBuffer2,a4
  479.                move.w #(GapLengthF+$2ec0+2),SLength
  480.                move.w StartTrack,d0
  481.                bsr HeadPos
  482.                move.w #NumReadsF-1,d2
  483. \TSF6:         bsr FastReads
  484.                move.w FirstBlock,FirstBlockSp  ;1. Block loaded
  485.                cmp.w #NoDisk,ErrorFlag
  486.                beq \TSF7
  487.                cmp.w #ReadError,ErrorFlag
  488.                bne \TSF5
  489.                dbf d2,\TSF6        ;branch, if reading  again
  490.                tst.l d0            ;No Sync found 
  491.                bpl \TSF1
  492.                move.l a4,a0              ;pass Buffer 
  493.                bsr DOSClear              ;store Track empty 
  494. \TSF1:
  495.                bsr RError                ;output error 
  496.                move.l a4,a0
  497.                move.l a5,a1
  498.                move.w StartTrack,d0      ;pass Track-Number
  499.                bsr CodeTrack      ;generate Track from data 
  500.                clr.w FirstBlockSp        ;first Block = 0
  501. \TSF5:         clr.l d0
  502. \TSF7:         movem.l (a7)+,d2/a2
  503.                rts
  504.  
  505. ;enter Gap Bytes in Track-Buffer 
  506. GapCreate:
  507.                move.l TrackBuffer1,a0
  508.                move.w #(GapLengthF/4)+4,d0
  509. \LS1:          move.l #$aaaaaaaa,(a0)+
  510.                dbf d0,\LS1
  511.                rts
  512.  
  513. TrackFVerify:
  514.                movem.l d2-d4/a4-a5,-(a7)
  515.                clr.w d3                ;Dest.-Counter
  516.                clr.w VerErrFlag        ;erase Verify-Error-Flag
  517.                move.b MotorBits,d4     ;store Motor Bits
  518. \TF2:          move.l TrackBuffer2,a5
  519.                move.l TrackBuffer1,a4
  520.                add.l #GapLengthF,a4
  521. \TF1:
  522.                move.b tr,d2            ;number of Write attempts
  523.                move.w d3,d1            ;Dest.-Number to D1
  524.                bsr SwitchND            ;switch on Destination 
  525.                tst.l d0                ;Drive present 
  526.                bmi \TF6                ;No 
  527. \TF4:          bsr FastVerify
  528.                cmp.w #NoDisk,ErrorFlag
  529.                beq \TF3                ;Error, No Disk
  530.                cmp.w #VerifyError,ErrorFlag
  531.                bne \TF6                ;no Error, continue
  532.                subq.b #1,d2            ;decrement Error-Counter
  533.                bne \TF5                ;continue if another attempt
  534.                bset d3,VerErrFlag      ;set Bit for Error
  535. \TF6:          addq.w #1,d3            ;increment Dest.number
  536.                cmpi.w #4,d3
  537.                bcs \TF1
  538.                bra \TF3                ;no additional Drives
  539. \TF5:          bsr TrackFastWrite
  540.                bra \TF4
  541. \TF3:          move.b d4,MotorBits
  542.                movem.l (a7)+,d2-d4/a4-a5
  543.                rts
  544.  
  545. TrackFastWrite:
  546.                move.l a5,-(a7)
  547.                move.l WriteAddrs,a5
  548.                move.w SLength,d0
  549.                move.w #NoIndex,d1
  550.                bsr Writer
  551.                move.l (a7)+,a5
  552.                rts
  553. DeepCopy:
  554.                move.b DD,d0
  555.                cmp.b SD,d0
  556.                beq \DC1
  557.                bra DeepCopyML          ;for several Drives
  558. \DC1:          bra DeepCopyEL          ;for one Drive
  559.  
  560. DeepCopyEL:
  561.                move.b #$aa,ShrtByte    ;ShortByte for Chruncher = aa
  562.                bsr NextMemory          ;assign memory
  563.                bsr insert_destination
  564.                tst.l d0
  565.                bmi \FCEL2
  566. \FCEL9:        bsr TestProtect
  567.                tst.l d0
  568.                bpl \FCEL10
  569.                bsr protect_Destination
  570.                tst.l d0
  571.                bmi \FCEL2              ;Escape activated
  572.                bra \FCEL9
  573. \FCEL10:       bsr LengthTest
  574.                move.w StartTrack,TrackNumS
  575.                move.w LenghtDest,d0    ;Length for Cruncher
  576.                addi.w #$10,d0
  577.                move.w d0,Length
  578. \FCEL11:       bsr insert_source
  579.                tst.l d0
  580.                bmi \FCEL2
  581. \FCEL1:        bsr TestProtect
  582.                tst.l d0
  583.                bmi \FCEL3
  584.                bsr protect_Source
  585.                tst.l d0
  586.                bmi \FCEL2              ;Escape activated
  587.                bra \FCEL1
  588. \FCEL3:        bsr DeepCopy1DL         ;read into memory
  589.                tst.l d0
  590.                bmi \FCEL2
  591. \FCEL7:        move.w TNumBufferA,StartTrack
  592.                bsr insert_destination
  593.                tst.l d0
  594.                bmi \FCEL2
  595. \FCEL5:        bsr TestProtect
  596.                tst.l d0
  597.                bpl \FCEL6
  598.                bsr protect_Destination
  599.                tst.l d0
  600.                bmi \FCEL2              ;Escape activated
  601.                bra \FCEL5
  602. \FCEL6:        bsr DeepCopy1DS         ;Write Tracks
  603.                tst.l d0
  604.                bmi \FCEL2
  605.                cmp.b #ON,ws            ;write several times ?
  606.                bne \FCEL8              ;no
  607.                bsr write_b_again
  608.                cmp.w #Escape,ErrorFlag
  609.                beq \FCEL2
  610.                tst.l d0
  611.                bpl \FCEL7              ; write again
  612. \FCEL8:        move.w StartTrack,TNumBufferA
  613.                move.w TNumBufferE,d0
  614.                cmp.w EndTrack,d0
  615.                bcs \FCEL11
  616. \FCEL2:        rts
  617.  
  618. DeepCopy1DL:
  619. \FCD1:         clr.w ErrorFlag
  620.                bsr TrackLS             ;load Track from Source
  621.                cmp.w #NoDisk,ErrorFlag
  622.                beq \Error
  623.                move.l TrackBuffer2,a0  ;pass Pointer
  624.                move.l WriteAddrs,a1
  625.                lea -6(a0),a0
  626.                move.l a1,(a0)
  627.                move.w SLength,4(a0)
  628.                bsr Packe               ;crunch Track
  629.                tst.l d0
  630.                bmi \FCD2               ;Memory full
  631.                bsr TextoutL
  632. \FCD3:         add.w #1,StartTrack
  633.                move.w StartTrack,d0
  634.                cmp.w EndTrack,d0
  635.                bls \FCD1
  636. \FCD2:         subq.w #1,StartTrack
  637.                clr.l d0
  638.                move.w StartTrack,TNumBufferE       ;Last Track
  639.                rts
  640. \Error:       move.l #-1,d0
  641.                rts
  642.  
  643. ;Copy part for writing with one Drive
  644. DeepCopy1DS:
  645.                move.w StartTrack,d0    ;first Track read
  646. \FDS1:         bsr HeadPos
  647.                bsr TextoutS
  648.                move.l TrackBuffer2,a0  ;Buffer for Track (Target)
  649.                lea -6(a0),a0
  650.                bsr EntPacke            ;Track again in normal size 
  651.                move.l TrackBuffer2,a0
  652.                move.l -6(a0),WriteAddrs
  653.                move.w -2(a0),SLength
  654.                move.l #$aaaaaaaa,-4(a0)
  655.                bsr TrackWriter
  656.                cmp.w #NoDisk,ErrorFlag
  657.                beq \Error
  658.                cmp.w #DiskProtect,ErrorFlag
  659.                bne \FDS3
  660.                bsr protect_destination
  661.                bra \Error
  662. \FDS3:         cmp.b #ON,vd            ;Verify ON ?
  663.                bne \FDS2               ;branch, when not on
  664. ;               bsr TrackFVerify
  665. ;               cmp.w #NoDisk,ErrorFlag
  666. ;               beq \Error
  667. ;               cmp.w #VerifyError,ErrorFlag
  668. ;               bne \FDS2
  669. ;               bsr WError
  670. \FDS2:         addq.w #1,StartTrack
  671.                move.w StartTrack,d0
  672.                cmp.w TNumBufferE,d0
  673.                bls \FDS1
  674.                clr.l d0
  675.                clr.w FreeFlagCh        ;Chip-Mem is free again
  676.                clr.w FreeFlagFa        ;Fast-Mem is free again
  677.                rts
  678. \Error:       move.l #-1,d0
  679.                rts
  680.  
  681.  
  682. DeepCopyML:
  683.                bsr SwitchD
  684. \DC5:          bsr TestProtect
  685.                tst.l d0
  686.                bpl \DC3
  687.                bsr protect_Destination
  688.                tst.l d0
  689.                bmi \Error              ;Escape activated
  690.                bra \DC5
  691. \DC3:          bsr LengthTest
  692.                tst.l d0
  693.                bmi \Error
  694. \DC1:
  695.                bsr TextoutL
  696.                bsr TrackLS             ;load Track from Source
  697.                cmp.w #NoDisk,ErrorFlag
  698.                beq \Error
  699.                bsr SwitchD
  700.                move.w StartTrack,d0
  701.                bsr HeadPos
  702.                bsr TextoutS
  703.                bsr TrackWriter
  704.                cmp.w #NoDisk,ErrorFlag
  705.                beq \Error
  706.                cmp.w #DiskProtect,ErrorFlag
  707.                bne \DC2
  708.                bsr protect_destination
  709.                bra \Error
  710. \DC2:          add.w #1,StartTrack
  711.                move.w StartTrack,d0
  712.                cmp.w EndTrack,d0
  713.                bls \DC1
  714. \Error:       rts
  715.  
  716.  
  717. ;load Track from Source or Destination.
  718. ;>= StartTrack = Track which will be loaded
  719.  
  720. TrackLS:       bsr SwitchS
  721.                move.l TrackBuffer1,a5
  722.                move.w StartTrack,d0
  723.                bsr HeadPos
  724.                bsr TrackLoader   
  725.                rts
  726.  
  727. ;Check length of Source- and Dest.-Diskette
  728. ;=>CheckLength = Length of Source-Disk
  729. ;=>LenghtDest   = Length of Dest.-Disk
  730. LengthTest:
  731.                bsr SwitchD
  732.                move.w StartTrack,d0
  733.                bsr HeadPos
  734.                move.l TrackBuffer2,a5
  735.                bsr erase
  736.                move.w #Bytesread-$15,d0
  737.                bsr Writer
  738.                tst.l d0
  739.                bmi \TD1                ;Disk write protected
  740.                bsr Counter
  741.                tst.l d0
  742.                bmi \TD1                ;No Disk in Drive
  743.                move.w CheckLength,LenghtDest
  744. \TD1:          rts
  745.  
  746. ;load Track after setting Motor Bits 
  747. ;>= A5 = Pointer to the Read buffer
  748. ;=> WriteAddrs = Pointer to Data for writing 
  749. ;=> SLength = Number of Bytes to be written
  750.  
  751. TrackLoader:
  752.                move.w #CopyAttempt1,CopyTry1
  753. Attempt1:
  754.                move.w #CopyAttempt2,CopyTry2 
  755. ;Attempts, on NoSync
  756. Attempt2:
  757.  
  758. ;measure length of Track (Index <=> Index)
  759. ;rad data without DMA in Buffer starting at A5
  760.  
  761.                move.w #NoError,ErrorFlag
  762.                bsr Counter         ;=> CheckLength = Length of Track
  763.                tst.l d0            ;Disk in Drive?
  764.                bmi \TrackLoaderEnd
  765.  
  766. ;measure distance from Index to Sync 
  767. ;if no Sync, then D0 = -1
  768. ;=> Syncwidth = distance to Sync
  769.  
  770.                bsr Syncdistance
  771.                tst.l d0
  772.                bpl \OK2
  773.                sub.w #1,CopyTry2
  774.                bne Attempt2
  775.  
  776. ;Program part when no Sync is found 
  777.  
  778. \TL7:          move.l TrackBuffer2,a5
  779.                bsr CopyOSync
  780.                bra \TL11
  781.  
  782. \OK2:
  783.                move.w CheckLength,d0
  784.                add.w #$100,d0
  785.                move.w #WithSync,d1
  786.                bsr loader
  787.                move.w SyncWord,(a5)      ;store first Sync 
  788.  
  789. ;determine number of Bytes to Track (Sync to Sync)
  790. ;=> D0 = -1, if number deviates too much from CheckLength 
  791. ;=> TrackBytes = Length of Track
  792.  
  793.                bsr SrchTEnd
  794.                tst.l d0
  795.                bpl \TL3
  796.                bsr SrchTEnd2
  797.                tst.l d0
  798.                bpl \TL3
  799.                sub.w #1,CopyTry1
  800.                bne Attempt1
  801.  
  802.                move.w CheckLength,TrackBytes
  803.                sub.w #$10,TrackBytes     ;if no End found 
  804.                                          ;shorten Track 
  805.  
  806. ;search for Gap if Sync was found 
  807. ;>= A5 Pointer to beginning of Track 
  808. ;=> Size1 = Size of the largest Block
  809. ;=> Size2 = Size of the second largest Block
  810.  
  811. ;=> SizePos = Position of the largest Block
  812. ;=> SyncNum = Number of Syncs found 
  813.  
  814. \TL3:
  815.                clr.l d0
  816.                move.w TrackBytes,d0
  817.                add.l a5,d0
  818.                move.l d0,EndPos
  819.  
  820.                bsr Blockidentify
  821.                cmp.w #SortBlockNum,SyncNum
  822.                bls \TL2                ;Number of Sync Ok
  823.  
  824. ;Too many Blocks for intermediate memory 
  825.  
  826.                move.l SizePos,BegPos   ;Gap in largest Block
  827.                bra \TL1                ;Too many Blocks to sort
  828. \TL2:
  829.                bsr TrackAmiga          ;Test if Amiga-Track
  830.                tst.l d0
  831.                bpl \TL4                ;branch if Amiga-Track
  832.                cmp.b #ON,sy            ;Sync correction
  833.                bne \TL5                ;no
  834. \TL4:          bsr Synccorrector
  835. \TL5:          bsr OrderBlocks
  836.                bsr SearchGap
  837. \TL1:          move.l TrackBuffer2,a4  ;Destination for copying
  838.                bsr Entirecopy
  839. \TL11:         clr.l d0                ;erase Error-Flag
  840. \TrackLoaderEnd:
  841.                rts
  842.  
  843. ;load Track which has no Sync 
  844. ;>= A5 = Track-Buffer
  845. ;=> GapLength = Length of Gap
  846. ;=> Syncwidth = 0  (no Sync)
  847. ;=> TrackBytes = Number of Bytes on the Track
  848.  
  849. CopyOSync:
  850.                movem.l d2-d3,-(a7)
  851.                move.w CheckLength,d0
  852.                cmp.w #Bytesread-50,d0    ;Source-Track too long
  853.                bcc \COS7
  854.                add.w #36,d0
  855.                bra \COS6
  856. \COS7:         move.w #Bytesread-50,CheckLength
  857.                move.w #Bytesread-16,d0
  858. \COS6:         move.w #WithoutSync,d1
  859.                bsr loader
  860.                tst.l d0
  861.                bmi \COS1
  862.                move.w CheckLength,d1
  863.                sub.w #50,d1
  864.  
  865.                move.l a5,a0              ;Track-Buffer
  866.                move.b (a0)+,d2           ;get first Byte 
  867. \COS2:         move.b (a0)+,d3
  868.                cmp.b d2,d3               ;compare Bytes 
  869.                bne \COS4                 ;not equal 
  870.                sub.w #1,d1               ;increase number 
  871.                bne \COS2
  872.                bra \COSOK                ;Track the same everywhere 
  873.  
  874. \COS4:         add.l #2,a0               ;jump over Gap 
  875.                move.b (a0)+,d2
  876. \COS3:
  877.                move.b (a0)+,d3
  878.                cmp.b d2,d3               ;compare Bytes 
  879.                bne \COSNO                ;not always the same 
  880.                sub.w #1,d1               ;increment Counter 
  881.                bne \COS3
  882.                move.l a5,a0
  883.  
  884. \COSOK:        move.w LenghtDest,d0
  885.                add.w #$10,d0
  886. \COS5:         move.b d2,(a0)+
  887.                dbf d0,\COS5
  888. \COSNO:        move.w LenghtDest,d0
  889.                add.w #$4,d0
  890.                move.w d0,TrackBytes
  891.                move.w d0,SLength         ;number of write bytes
  892.                move.l a5,WriteAddrs      ;beginning of Data 
  893.                move.w #NoSync,ErrorFlag
  894.                clr.l d0
  895.                movem.l (a7)+,d2-d3
  896.                rts
  897. \COS1:         move.l #-1,d0
  898.                rts
  899.  
  900. TrackWriter:
  901.                move.l WriteAddrs,a5
  902.                move.w SLength,d0
  903.                bsr Writer
  904.                rts
  905. erase:
  906.                move.l TrackBuffer2,A0
  907.                move.w #(Bytesread-$10)/4,d0
  908. \ER2:          move.l #$aaaaaaaa,(a0)+
  909.                dbf d0,\ER2
  910.                rts
  911.  
  912. ;determine copy area (Start- and End-Cylinder)
  913. ;>= StartTrack = Track where start is made (Track!!)
  914. ;>= EndTrack   = Track which is copied last (Track!!)
  915.  
  916. Start_End:     clr.l d0
  917.                move.b fc,d0              ;first Cylinder
  918.                lsl.b #1,d0               ;Cylinder => Track
  919.                move.w d0,StartTrack
  920.                move.w d0,TNumBufferA
  921.                move.b lc,d0              ;last Cylinder
  922.                lsl.b #1,d0               ;Cylinder => Track
  923.                add.w #1,d0               ;last Track = bottom side
  924.                move.w d0,EndTrack
  925.                rts
  926.  
  927. ;test if Disk is in the Drive
  928. ;=> D0 = -1, if no Disk in the Drive
  929.  
  930. DiskInFloppy:
  931.                clr.l d0
  932.                move.b $bfe001,d0
  933.                btst #2,d0
  934.                bne \DIF
  935.                move.l #-1,d0
  936.                move.w #NoDisk,ErrorFlag
  937. \DIF:          rts
  938.  
  939. ;load Track 
  940. ;A5 = Pointer to Data-Buffer
  941.  
  942. Loader:        MOVEM.L d2-d3,-(A7)
  943.                move.w d0,d3              ;read Byte num
  944.                lsr.w #1,d3
  945.                bsr DiskInFloppy
  946.                tst.l d0
  947.                bmi \L1
  948.                MOVE.W #$8010,$DFF096     ;enable Disk-DMA 
  949.                move.w #$7f00,$DFF09E     ;erase Disk-Bits 
  950.                MOVE.L A5,A1              ;Pointer to Data-Buffer
  951.                MOVE.L A1,$DFF020         ;pass Data-Buffer 
  952.                cmp.w #WithSync,d1
  953.                bne \L3
  954.                MOVE.W SyncWord,$DFF07E   ;pass SYNC-Word 
  955.                move.w #$8500,$DFF09E
  956.                lea 2(a5),a1
  957.                move.l a1,$DFF020         ;pass new Address 
  958.                bra \L4
  959.  
  960. \L3:           MOVE.W #$8100,$DFF09E     ;To MFM-Format
  961. \L4:           MOVE.W #$4000,$DFF024     ;prepare transmission
  962.                bsr Index                 ;wait to Index 
  963.                tst.l d0
  964.                bmi \L1
  965.                or.w #$8000,d3
  966.                MOVE.W d3,$DFF024
  967.                MOVE.W d3,$DFF024         ;read Data 
  968.                clr.l d0                  ;report Ok 
  969.                MOVE.L #$18000,D1         ;set time counter 
  970.                move.w #$0002,$dff09c     ;erase Blockdone-Int. 
  971. \L2:           MOVE.W $DFF01E,D2
  972.                BTST #1,D2
  973.                BNE.S \L1             ;wait for Disk-Block-Ready
  974.                SUBQ.L #1,D1          ;decrement Counter
  975.                BNE.S \L2             ;branch when not done 
  976.                move.l #-1,d0
  977. \L1:           MOVE.W #$4000,$DFF024
  978. \L5:           MOVEM.L (A7)+,D2-d3
  979.                RTS
  980.  
  981. ;wait for Index hole 
  982.  
  983. Index:
  984.                move.l d1,-(a7)
  985.                clr.l d0
  986.                move.l #$30000,d1
  987.                MOVE.B $BFDD00,D0
  988. Index1:        MOVE.B $BFDD00,D0         ;wait for Index hole 
  989.                BTST #4,D0
  990.                Bne.s Index2
  991.                sub.l #1,d1
  992.                bne Index1
  993.                move.l #-1,d0
  994. Index2:
  995.                move.l (a7)+,d1
  996.                rts
  997.  
  998.  
  999. ;determine Motorbits, set Heads to zero
  1000. HeadMov:
  1001.                movem.l d2-d4,-(a7)
  1002.                clr.w d3
  1003.                move.b DD,d2             ;Dest.-Drives
  1004.                or.b SD,d2               ;Source-Drives
  1005. \KA1:          clr.l d0
  1006.                btst d3,d2               ;Drive now in use ?
  1007.                beq \KA2                 ;not in use 
  1008.                bset d3,d0               ;Bit for Drive
  1009.                lsl.b #3,d0
  1010.                eor.b #$fb,d0
  1011.                move.b d0,MotorBits
  1012.                bsr MotorOn
  1013.                clr.l d0
  1014.                bsr HeadPos
  1015. \KA2:
  1016.                addq.w #1,d3
  1017.                cmp.w #4,d3
  1018.                bne \KA1
  1019.  
  1020.                bsr MotBits
  1021.                move.b MotorBitsD,MotorBits
  1022.                move.b #-1,Flag
  1023.                clr.w TrackNumS
  1024.                clr.w TrackNumD
  1025.                bsr SwitchS
  1026.                movem.l (a7)+,d2-d4
  1027.                rts
  1028. TestDrive:
  1029.                move.l a0,-(a7)
  1030.                lea $bfd000,a0
  1031.                bclr #1,MotorBits
  1032.                bsr Stepper
  1033.                bset #1,MotorBits
  1034.                bsr Stepper
  1035.                move.l (a7)+,a0
  1036.                rts
  1037.  
  1038. ;=> D0 = -1 => Disk protect
  1039. TestProtect:   bsr TestDrive
  1040.                clr.w ErrorFlag
  1041.                move.b $bfe001,d0
  1042.                btst #3,d0
  1043.                bne \TP2
  1044.                move.w #DiskProtect,ErrorFlag
  1045.                move.l #-1,d0
  1046.                bra \TP1
  1047. \TP2:          clr.l d0
  1048. \TP1:          rts
  1049.  
  1050. ;place Head in position indicated by D0 
  1051.   
  1052. HeadPos:       MOVEM.L D0-D3,-(A7)
  1053.                lea $bfd000,a0
  1054.                tst.w d0
  1055.                beq HeadNull
  1056.                move.w TrackNum,d2      ;current Track-Number
  1057.                CMP.W d2,D0
  1058.                BEQ.S Headend           ;End when right Track
  1059.                move.w d0,d3            ;Track-Number to D3
  1060.                move.b MotorBits,d1
  1061.                bset #2,d1              ;lower Head 
  1062.                btst #0,d3
  1063.                beq Upper               ;select lower Head 
  1064.                bclr #2,d1
  1065. Upper:         move.b d1,MotorBits     ;upper Head
  1066.                move.b d1,$100(a0)
  1067.                move.w d3,TrackNum
  1068.                lsr.w #1,d2
  1069.                lsr.w #1,d3             ;calculate steps 
  1070.                sub.w d3,d2
  1071.                bcs.s In
  1072.                bhi.s Out
  1073.                bra Headend
  1074. In:            bclr #1,d1
  1075.                move.b d1,MotorBits
  1076.                neg.w d2
  1077.                bra.s rechok
  1078. Out:           bset #1,d1
  1079.                move.b d1,MotorBits
  1080.                bra.s rechok
  1081. Heads:         bsr Stepper
  1082. rechok:        dbf d2,Heads
  1083. Headend:       movem.l (a7)+,d0-d3
  1084.                rts
  1085.  
  1086. HeadNull:
  1087.                move.b Motorbits,d1
  1088.                bset #2,d1
  1089.                bset #1,d1
  1090.                move.b d1,Motorbits
  1091.                clr.w TrackNum
  1092. HeadNull1:     move.b $bfe001,d0
  1093.                btst #4,d0
  1094.                beq.s \He1
  1095.                bsr Stepper
  1096.                bra HeadNull1
  1097. \He1:          bclr #1,MotorBits
  1098.                bsr Stepper
  1099.                bset #1,MotorBits
  1100.                bsr Stepper
  1101.                bra Headend
  1102.  
  1103. Stepper:
  1104.                move.b MotorBits,d0
  1105.                lea $100(a0),a1
  1106.                move.b d0,d1
  1107.                bclr #0,d0
  1108.                move.b d0,(a1)
  1109.                nop
  1110.                nop
  1111.                move.b d1,(a1)
  1112.                jsr Timer
  1113.                move.b MotorBits,(a1)
  1114.                rts
  1115.  
  1116. ;Wait loop
  1117.  
  1118. Timer:         MOVE.L D7,-(A7)
  1119.                MOVE.W #2500,D7
  1120. \L1:           DBRA D7,\L1
  1121.                MOVE.L (A7)+,D7
  1122.                RTS
  1123. Timer2:        MOVE.L D7,-(A7)
  1124.                MOVE.L #$6000,D7
  1125. \L1:           sub.l #1,D7
  1126.                bne \L1
  1127.                MOVE.L (A7)+,D7
  1128.                RTS
  1129.  
  1130. ;Motor routine:   D0=0 => Motor off 
  1131.  
  1132. MotorOff:      clr.l d0
  1133.                bra Motor
  1134. MotorOn:       move.b #$01,d0
  1135.  
  1136. Motor:         movem.l d1/d2,-(a7)
  1137.                lea $bfd000,a0
  1138.                tst d0
  1139.                seq d1
  1140.                andi.b #$80,d1
  1141.                move.b MotorBits,d2
  1142.                andi.b #$80,d2
  1143.                cmp.b d1,d2
  1144.                beq.s Mook
  1145.                bclr #7,MotorBits
  1146.                or.b d1,MotorBits
  1147.                move.b #$ff,d1
  1148.                eor.b d2,d1
  1149.                move.b d1,$100(a0)
  1150.                move.b MotorBits,$100(a0)
  1151.                btst #7,MotorBits
  1152.                bne Mook
  1153.                jsr Timer2
  1154. Mook:          movem.l (a7)+,d1/d2
  1155.                rts
  1156.  
  1157. Disable:       move.w #$4000,$dff09a
  1158.                move.l a6,-(a7)
  1159.                move.l $4,a6
  1160.                add.b #1,IDNestCnt(a6)
  1161.                move.l (a7)+,a6
  1162.                rts
  1163. Enable:        move.l a6,-(a7)
  1164.                move.l $4,a6
  1165.                sub.b #1,IDNestCnt(a6)
  1166.                bge L005
  1167.                move.w #$c000,$dff09a
  1168. L005:          move.l (a7)+,a6
  1169.                rts
  1170.  
  1171. ;Waits for Byte during read and stores Byte (a0)+
  1172.  
  1173.                rts
  1174.  
  1175. ;>= a0 = Address of data to be found 
  1176. ;>= A1 = Address where search starts 
  1177. ;>= Searchln = Number of words for error
  1178. ;>= NumWords = Number of Words which is compared 
  1179. ;=> D1 = Number of Bytes to fund
  1180. ;=> Position = where found 
  1181. ;=> D0 = -1 = not found 
  1182. ;=> A0 = Position where found 
  1183.  
  1184. Bitsrch:
  1185.                movem.l d2-d6/a2-a4,-(a7)
  1186.                move.l a0,a2
  1187.                move.l a1,a3
  1188.                clr.w d5
  1189.                move.w Searchln,d4        ;Search num
  1190. srch2:         move.w #00,d3             ;number of shift Bits 
  1191. srch1:         move.l (a2),d1
  1192.                move.l (a3),d2
  1193.                bsr comp
  1194.                tst.w d0
  1195.                beq srchok
  1196.                move.l a0,a2
  1197.                tst.w d5
  1198.                beq srch4
  1199.                clr.w d5
  1200.                move.w d6,d3
  1201.                move.l a4,a3
  1202.   
  1203. srch4:         add.w #1,d3
  1204.                cmp.w #$10,d3
  1205.                bne srch1
  1206. srch3:         add.l #2,a3
  1207.                clr.w d5                  ;compare the right ones 
  1208.                dbf d4,srch2              ;Counter for attempts 
  1209.                move.l #-1,d0             ;not found 
  1210.                bra srchend
  1211. srchok:
  1212.                tst.w d5
  1213.                bne srchok2
  1214.                move.l a3,a4
  1215.                move.w d3,d6
  1216.  
  1217. srchok2:       add.w #1,d5
  1218.                cmp.w NumWords,d5
  1219.                beq srchend1
  1220.                add.l #2,a2
  1221.                add.l #2,a3
  1222.                bra srch1
  1223. srchend1:      move.l #0,d0
  1224.                sub.w #1,d5
  1225.                lsl.w #1,d5
  1226.                suba.l d5,a3
  1227.                move.l a3,a0
  1228.                move.l a3,Position
  1229.                move.l a3,a0           ;Position
  1230.                move.w d3,BitShifts    ;Bit shifting 
  1231.                sub.l a1,a3
  1232.                move.l a3,d1           ;Number of Bytes until found 
  1233. srchend:       movem.l (a7)+,d2-d6/a2-a4
  1234.                rts
  1235. comp:          movem.l d1-d2,-(a7)
  1236.                lsl.l d3,d2
  1237.                swap d1
  1238.                swap d2
  1239.                eor.w d1,d2
  1240.                move.w d2,d0
  1241.                movem.l (a7)+,d1-d2
  1242.                rts
  1243.  
  1244.  
  1245.  
  1246. MotBits:
  1247.                move.b SD,d0              ;Source-Disk
  1248.                lsl.b #3,d0
  1249.                eor.b #$fb,d0
  1250.                move.b d0,MotorBitsS
  1251.                move.b DD,d0              ;Dest.-Disk
  1252.                lsl.b #3,d0
  1253.                eor.b #$fb,d0
  1254.                move.b d0,MotorBitsD
  1255.                rts
  1256.  
  1257. ;switch on next Dest.-Drive 
  1258. ;!!! Caution !!! old Motorbits are reset 
  1259. ;>= D1 = which Drive ( < 4)
  1260. ;=> D0 = -1, if no additional Drive available 
  1261. ;=> D0 = Null if OK
  1262.  
  1263. SwitchND:
  1264.                move.l d2,-(a7)
  1265.                clr.l d0
  1266.                move.b DD,d2
  1267.                btst d1,d2                ;Drive connected ?
  1268.                bne \SND1                 ;yes, connected 
  1269.                move.l #-1,d0
  1270.                bra \SND2
  1271. \SND1:         bset d1,d0                ;Bit for Drive
  1272.                lsl.b #3,d0
  1273.                eor.b #$7b,d0
  1274.                move.w StartTrack,d1
  1275.                bset #2,d0
  1276.                btst #0,d1
  1277.                beq \SND3                 ;lower Head select 
  1278.                bclr #2,d0
  1279. \SND3:         move.b d0,MotorBits       ;upper Head
  1280.                move.b d0,$bfd100
  1281.                clr.l d0
  1282. \SND2:         move.l (a7)+,d2
  1283.                rts
  1284.  
  1285. SwitchS:
  1286.                tst.b Flag
  1287.                bpl \S1
  1288.                move.b MotorBits,MotorbitsD
  1289.                move.w TrackNum,TrackNumD
  1290.                move.b MotorBitsS,MotorBits
  1291.                move.w TrackNumS,TrackNum
  1292.                move.b #$7f,$bfd100
  1293.                move.b MotorBits,d0
  1294.                bclr #7,d0
  1295.                move.b d0,$bfd100
  1296.                move.b d0,MotorBits
  1297.                clr.b Flag
  1298. \S1:           rts
  1299. SwitchD:
  1300.                tst.b Flag
  1301.                bmi \S1
  1302.                move.b MotorBits,MotorbitsS
  1303.                move.w TrackNum,TrackNumS
  1304.                move.b MotorBitsD,MotorBits
  1305.                move.w TrackNumD,TrackNum
  1306.                move.b #$7f,$bfd100
  1307.                move.b MotorBits,d0
  1308.                bclr #7,d0
  1309.                move.b d0,$bfd100
  1310.                move.b d0,MotorBits
  1311.                move.b #-1,Flag
  1312. \S1:           rts
  1313.  
  1314.  
  1315. ;store Track 
  1316. ;>= D0 = number of Bytes to write 
  1317. ;>= A5 = Track-Buffer
  1318. ;>= D1 = Indication if wait for Index (IndexOk/NoIndex)
  1319.  
  1320. Writer:     MOVEM.L D2-D3,-(A7)
  1321.                move.w d1,d2
  1322.                move.w d0,d3              ;Number to D3
  1323.                clr.w ErrorFlag
  1324.                bsr DiskInFloppy
  1325.                tst.l d0
  1326.                bmi \Protect
  1327.                move.b $bfe001,d0
  1328.                btst #3,d0
  1329.                bne \SR5
  1330.                move.w #DiskProtect,ErrorFlag
  1331.                bra \Protect
  1332. \SR5:          lsr.w #1,d3               ;from Byte make Word
  1333.                jsr MotorOn
  1334.                MOVE.W #2,$DFF09C         ;erase Disk-Block-Int. 
  1335.                MOVE.L A5,$DFF020         ;pass Data-Buffer 
  1336.                MOVE.W #$8210,$DFF096     ;enable Disk-DMA 
  1337.                move.w #$7f00,$dff09e
  1338.                MOVE.W #$8100,$DFF09E     ;MFM-Format
  1339.                cmp.w #80,StartTrack
  1340.                bcs \SR1
  1341.                move.w #$a000,$dff09e     ;Pre-compensation
  1342. \SR1:          MOVE.W #$4000,$DFF024     ;prepare transmission 
  1343.                cmp.w #NoIndex,d2
  1344.                beq \SR2
  1345.                bsr Index
  1346.                tst.l d0
  1347.                bmi \Protect
  1348. \SR2:          or.w #$c000,d3            ;switch to write 
  1349.                MOVE.W d3,$DFF024
  1350.                MOVE.W d3,$DFF024         ;write Data 
  1351.                clr.l d0                  ;pass OK message 
  1352.                MOVE.L #$20000,D1         ;set time counter 
  1353. \SR3:          MOVE.W $DFF01E,D2
  1354.                BTST #1,D2
  1355.                BNE.S \SR4            ;wait for Disk-Block-Ready 
  1356.                SUBQ.L #1,D1          ;decrement Counter 
  1357.                BNE.S \SR3            ;branch when not done 
  1358. \Protect:      move.l #-1,d0
  1359. \SR4:          move.w #$4000,$dff024
  1360.                MOVEM.L (A7)+,D2-D3
  1361.                RTS
  1362. ;Searches for Track-End when Sync found 
  1363. ;>= A5 = Pointer to Track-Buffer (Sync found)
  1364. ;=> TrackBytes = Number of Bytes on the Track (seek for Sync)
  1365. ;=> D0 = -1, too much deviation from CheckLength
  1366.  
  1367. SrchTEnd:
  1368.                move.l a5,a0
  1369.                clr.l d0
  1370.                move.w CheckLength,d0
  1371.                sub.w #$4,d0
  1372.                adda.l d0,a0
  1373.                move.w #$10,d0
  1374.                bsr SrchSync
  1375.                tst.l d0
  1376.                bmi \STE2
  1377.                suba.l a5,a0
  1378.                sub.w #2,a0
  1379.                move.w a0,TrackBytes
  1380.                rts
  1381. \STE2:         move.l #-1,d0
  1382.                move.w #LengthUnequal,ErrorFlag
  1383.                rts
  1384.  
  1385. SrchTEnd2:
  1386.                move.l a5,a0
  1387.                adda.l #$04,a0
  1388.                move.l a0,a1
  1389.                clr.l d0
  1390.                move.w CheckLength,d0
  1391.                sub.w #$40,d0
  1392.                adda.l d0,a1
  1393.                move.w #$40,Searchln
  1394.                move.w #$60,NumWords
  1395.                bsr Bitsrch
  1396.                tst.l d0
  1397.                bmi \STE2
  1398.                suba.l a5,a0
  1399.                suba.l #6,a0              ;Position before Sync
  1400.                move.w a0,TrackBytes
  1401.                rts
  1402. \STE2:         move.l #-1,d0
  1403.                move.w #LengthUnequal2,ErrorFlag
  1404.                rts
  1405.  
  1406. ;search for Blocks and store
  1407. ;>= A5 = Pointer to Track beginning 
  1408. ;=> Size1 = Size of the largest Block
  1409. ;=> Size2 = Size of the second largest Block
  1410. ;=> SizePos = Position of the largest Block
  1411. ;=> SyncNum = Number of Syncs found
  1412. ;=> Blocks = Buffer in which the Block sizes are stored
  1413. Blockidentify: movem.l d2-d4/a3,-(a7)
  1414.                move.w TrackBytes,d2      ;Bytes on Track
  1415.                move.l a5,a3              ;Beginning of Track
  1416.                clr.w Size1
  1417.                clr.w Size2
  1418.                clr.w SyncNum
  1419.                clr.w d3
  1420.  
  1421. \S2:           move.w d2,d0
  1422.                move.l a3,a0              ;where to start search 
  1423.                bsr SrchSyncF
  1424.                tst.l d0
  1425.                bmi \S5                   ;End
  1426.                tst.w d1
  1427.                beq \S6
  1428.                move.w d3,d4
  1429.                add.w d1,d3               ;Number + Sync
  1430.                bsr Blockentry
  1431.                bsr Size
  1432.                clr.w d3                  ;Sync gap = 0
  1433. \S6:
  1434.                add.w #2,d3               ;Sync gap +2
  1435.                add.w #2,d1
  1436.                andi.l #$ffff,d1
  1437.                adda.l d1,a3
  1438.                sub.w d1,d2
  1439.                bcc \S2
  1440.                bra \S7
  1441. \S5:           move.w d2,d1
  1442.                add.w #2,d1               ;Number +2
  1443.                move.w d3,d4              ;Sync message 
  1444.                add.w d1,d3               ;Number + Syn
  1445.                bsr Blockentry
  1446.                bsr Size
  1447. \S7:           movem.l (a7)+,D2-d4/A3
  1448.                rts
  1449.  
  1450. ;Enter size of Blocks
  1451. ;>= D1 = Block size 
  1452.  
  1453. Size:
  1454.                cmp.w Size1,d3
  1455.                bcs \S3
  1456.                move.w Size1,Size2
  1457.                move.w d3,Size1
  1458.                move.l a0,a1
  1459.                move.l a1,SizePos
  1460.                bra \S4
  1461. \S3:           cmp.w Size2,d3
  1462.                bcs \S4
  1463.                move.w d1,Size2
  1464. \S4:           rts
  1465.  
  1466. Blockentry:
  1467.                move.w SyncNum,d0
  1468.                cmp.w #$40,d0             ;Too many Blocks ?
  1469.                bcc \S1                   ;yes, do not store 
  1470.                lsl.w #2,d0
  1471.                lea Blocks,a1
  1472.                lsr.w #1,d4
  1473.                move.w d4,(a1,d0)
  1474.                add.w #2,d0
  1475.                move.w d3,(a1,d0)         ;store Block 
  1476. \S1:           add.w #1,SyncNum
  1477.                rts
  1478.  
  1479. ;seek Sync-Mark (fast)
  1480. ;>= A0 = Search address
  1481. ;>= D0 = Byte number for errors permitted
  1482. ;=> A0 = Sync address
  1483. ;=> D0 = -1, no Sync found 
  1484. ;=> D1 = found after xx Bytes 
  1485. SrchSyncF:
  1486.                lsr.w #1,d0               ;from Byte make Word
  1487.                move.l a0,a1
  1488. \SSF2:         cmp.w #$4489,(a0)+
  1489.                beq \SSF1
  1490.                dbf d0,\SSF2
  1491.                move.l #-1,d0
  1492.                bra \SSF3
  1493. \SSF1:         suba.l #2,a0
  1494.                move.l a0,d0
  1495.                sub.l a1,a0
  1496.                move.w a0,d1
  1497.                move.l d0,a0
  1498.                clr.l d0
  1499. \SSF3:         rts
  1500. ;search for Sync-Mark 
  1501. ;>= A0 = Search address
  1502. ;>= D0 = Byte number for errors permitted 
  1503. ;=> A0 = Sync address
  1504. ;=> D0 = -1, no Sync found 
  1505. ;=> D1 = found after  xx Bytes 
  1506. ;=> BitShifts = shifted by xx Bits 
  1507.  
  1508.  
  1509.  
  1510. SrchSync:
  1511.                movem.l d2-d4/a2,-(a7)
  1512.                move.l a0,a2
  1513.                lsr.w #2,d0         ;Byte out, with longword value
  1514.                lea SyncBase,a1
  1515. \SS3:          clr.l d1
  1516.                move.l #$ffff0000,d3
  1517.                move.l (a0)+,d2
  1518. \SS2:          move.l d2,d4
  1519.                and.l d3,d4
  1520.                cmp.l (a1,d1),d4
  1521.                beq \SS1
  1522.                add.w #4,d1
  1523.                lsr.l #1,d3
  1524.                cmp.w #$40,d1
  1525.                bls \SS2
  1526.                dbf d0,\SS3
  1527.                move.l #-1,d0
  1528.                bra \SS4
  1529. \SS1:          clr.l d0
  1530.                lsr.w #2,d1
  1531.                move.w d1,BitShifts
  1532.                cmp.w #$8,d1
  1533.                bcc \SS5
  1534.                suba.l #2,a0
  1535. \SS5:          suba.l #2,a0
  1536.                move.l a0,d1
  1537.                suba.l a2,a0
  1538.                exg.l a0,d1
  1539. \SS4:          movem.l (a7)+,d2-d4/a2
  1540.                rts
  1541.  
  1542. ;Distance Index <=> Sync
  1543. ;=> Syncwidth = Distance Index <=> Sync
  1544. ;=> D0 = -1, no Sync found 
  1545.  
  1546. Syncdistance:
  1547.                move.l a5,a0
  1548.                move.w CheckLength,d0
  1549.                bsr SrchSync
  1550.                tst.l d0
  1551.                bpl \SE1
  1552.                move.w #NoSync,ErrorFlag
  1553.                bra \SE2
  1554. \SE1:
  1555.                move.w d1,Syncwidth
  1556. \SE2:          rts
  1557.  
  1558. ;A5 = TrackBuffer
  1559.  
  1560. ;Counter of Data on Disk without Sync and without DMA
  1561. ;>= A5 = Pointer to Verify-Buffer for reading Data without Sync
  1562. ;=> CheckLength = Length of a Track (From Index to Index)
  1563.  
  1564. Counter:
  1565.                bsr DiskInFloppy
  1566.                tst.l d0
  1567.                bmi \Z5
  1568.                movem.l d2-d4/a2-a3,-(a7)
  1569.                move.w #$0600,$dff09e     ;switch Sync off 
  1570.                move.w #$8000,$dff024
  1571.                lea $dff01b,a0
  1572.                lea $dff01a,a1
  1573.                lea $bfdd00,a2
  1574.                move.l #15,d2
  1575.                move.l #4,d3
  1576.                move.w #1,d4
  1577.                clr.w d0
  1578.                move.b (a2),d1            ;erase Byte-Ready-Flag 
  1579. \Z4:           move.b (a2),d1
  1580.                btst #4,d1
  1581.                beq.s \Z4
  1582.                move.w (a1),d1            ;erase Byte-Ready-Flag 
  1583.                move.b (a2),d1            ;erase Indexbit 
  1584.                move.l a5,a3
  1585. \Z1:
  1586.                btst d2,(a1)
  1587.                beq.s \Z1
  1588.                btst d3,(a2)
  1589.                bne.s \Z2
  1590.                add.w d4,d0
  1591.                move.b (a0),(a3)+
  1592.                bra \Z1
  1593. \Z2:
  1594.                andi.w #$fffe,d0
  1595.                move.w d0,CheckLength
  1596.                cmp.w #Bytesread,d0       ;Track too long 
  1597.                bcs \Z6
  1598.                move.w #Bytesread-16,CheckLength
  1599. \Z6:           bclr #31,d0               ;erase Errorbit 
  1600.                movem.l (a7)+,d2-d4/a2-a3
  1601. \Z5:           move.w #$4000,$dff024
  1602.                rts
  1603.  
  1604. ;Sort Block sizes 
  1605.  
  1606. OrderBlocks:
  1607.                move.l d2,-(a7)
  1608.                cmp.w #SortBlockNum,SyncNum
  1609.                bhi \OBEND                ;too many Blocks 
  1610.                tst.w SyncNum
  1611.                beq \OBEND                ;no Blocks 
  1612.                clr.w NumSortBlock
  1613.                lea Blocks,a0
  1614.                move.w SyncNum,d0
  1615. \OB5:          move.l (a0)+,d1
  1616.                sub.w #1,d0
  1617.                lea SortBlocks,a1         ;Number of Blocks -1
  1618.                move.w NumSortBlock,d2
  1619.                tst.w d2
  1620.                beq \OB2                  ;first Block
  1621. \OB4:          cmp.w (a1)+,d1
  1622.                bne \OB3                  ;found 
  1623.                add.w #1,(a1)
  1624.                bra \OB6
  1625. \OB3:          adda.w #2,a1
  1626.                sub.w #1,d2
  1627.                bne \OB4                  ;continue search 
  1628. \OB2:          move.w d1,(a1)+
  1629.                move.w #1,(a1)+
  1630.                add.w #1,NumSortBlock
  1631. \OB6:          tst.w d0
  1632.                bne \OB5                  ;new search 
  1633. \OBEND:        move.l (a7)+,d2
  1634.                rts
  1635.  
  1636. SearchGap:
  1637.                move.l d2,-(a7)
  1638.                clr.l BegPos
  1639.                move.w NumSortBlock,d0
  1640.  
  1641.                cmp.b #1,dc1
  1642.                beq \SL10        ;DeepCopy 1 (Gap after large Block)
  1643.  
  1644. ;search for single Blocks
  1645.  
  1646.                sub.w #1,d0               ;Block number -1
  1647. \SL3:
  1648.                bsr SingleBlock           ;search for single Block
  1649.                tst.l d0                  ;Gap found ?
  1650.                bpl \SL7                  ;branch when not found 
  1651. \SL10:         move.l SizePos,a0         ;Gap with largest Block
  1652. \SL7:
  1653.                move.l A0,BegPos
  1654.                cmp.l EndPos,a0
  1655.                bcs \SL8
  1656.                move.l a5,a0
  1657.                move.l a0,BegPos
  1658. \SL8:
  1659.                move.l SizePos,d0
  1660.                cmp.l EndPos,d0
  1661.                bcs \SL9
  1662.                move.l a5,SizePos
  1663. \SL9:          move.l (a7)+,d2
  1664.                rts
  1665.  
  1666.  
  1667.  
  1668. ;Search for single Block 
  1669. ;=> D0 = Block number
  1670. ;=> D0 = Block number of next Block
  1671. ;=> D0 = -1, when none found 
  1672. ;=> D1 = Size of Block
  1673. ;=> a0 = Address of the Blocks
  1674.  
  1675. SingleBlock:
  1676.                movem.l d2-d4,-(a7)
  1677.                and.l #$ffff,d0           ;erase error message
  1678.                tst.w d0
  1679.                bmi \EB3
  1680.                lea SortBlocks,a0
  1681. \EB2:          move.w d0,d1
  1682.                lsl.w #2,d1
  1683.                move.l (a0,d1),d2
  1684.                cmp.w #1,d2
  1685.                beq \EB1                  ;Block found 
  1686.                sub.w #1,d0
  1687.                tst.w d0
  1688.                bpl \EB2
  1689. \EB3:          move.l #-1,d0
  1690.                bra \EBEND                ;Error 
  1691. \EB1:          move.w (a0,d1),d2         ;Block length 
  1692.                clr.w d3                  ;erase Blockadr. 
  1693.                lea Blocks,a0
  1694. \EB4:          move.l (a0)+,d1
  1695.                add.w d1,d3               ;determine Address 
  1696.                cmp.w d1,d2
  1697.                bne \EB4                  ;continue if not done
  1698.                sub.l a0,a0               ;clear A0
  1699. \EB5:          move.w d3,a0              ;Offset
  1700.                add.l a5,a0               ;Address
  1701.                move.w d2,d1              ;Block size
  1702.                sub.w #1,d0               ;Number of next Block
  1703. \EBEND:        movem.l (a7)+,d2-d4
  1704.                rts
  1705.  
  1706. ;Test if Track on Amiga-Format
  1707. ;=> D0 = Null, if Track Amiga-Format
  1708. ;=> D0 = -1, if not Amiga-Format
  1709. TrackAmiga:
  1710.                move.l d2,-(a7)
  1711.                lea Blocks,a0          ;Pointer to Block storage 
  1712.                cmp.w #$0b,SyncNum     ;SyncNumahl for Amiga-Format
  1713.                bne \PL1               ;No not Amiga-Format
  1714.                clr.w d1
  1715.                clr.l d2
  1716.                move.w #$0a,d0
  1717. \PL3:          move.w d0,d2
  1718.                lsl.w #2,d2
  1719.                cmp.w #$0440,2(a0,d2)    ;Block length for Amiga
  1720.                bne \PL2
  1721.                add.w #1,d1
  1722. \PL2:          dbf d0,\PL3
  1723.                cmp.w #$9,d1             ;at least 9 Amiga-Blocks 
  1724.                bcs \PL1
  1725.                clr.l d0                 ;OK, Amiga-Format
  1726.                move.b #ON,AmigaTrack
  1727. \PL4:          move.l (a7)+,d2
  1728.                rts
  1729. \PL1:          move.l #-1,d0            ;not Amiga-Format
  1730.                move.b #OFF,AmigaTrack
  1731.                bra \PL4
  1732. ;The program assumes that all Syncs are equal in length
  1733. ;all Syncs are fitted to the first 
  1734. ;>= A5 = Pointer to Track-Buffer
  1735.  
  1736. Synccorrector:
  1737.                movem.l d2-d4,-(a7)
  1738.                cmp.w #1,SyncNum
  1739.                beq \SK1                 ;only one Sync
  1740.                lea Blocks,a0
  1741.                clr.w d0
  1742.                clr.l d3
  1743.                move.l a5,a1
  1744.                move.l (a0)+,d2
  1745.                move.w d2,d3             ;Block length
  1746.                swap d2                  ;Sync value
  1747. \SK3:          adda.l d3,a1             ;Pointer to Block
  1748.                add.w #1,d0
  1749.                cmp.w SyncNum,d0
  1750.                bcc \SK1
  1751.                move.l (a0)+,d1
  1752.                move.w d1,d3             ;Block length
  1753.                swap d1                  ;SyncNum from Block
  1754.                cmp.w d2,d1
  1755.                bcc \SK3                 ;do not correct
  1756.                sub.w d2,d1
  1757.                not.w d1
  1758.                move.w d1,d4             ;Number of new Syncs
  1759.                move.l a1,-(a7)
  1760. \SK2:
  1761.                cmp.l SizePos,a1         ;must Pos be changed 
  1762.                bne \SK8
  1763.                sub.l #2,SizePos         ;change SizePos 
  1764. \SK8:          move.w #$4489,-(a1)
  1765.  
  1766.                dbf d4,\SK2
  1767.                move.l (a7)+,a1
  1768.                add.w #1,d1
  1769.                add.w d1,-4(a0)
  1770.                lsl.w #1,d1
  1771.                sub.w d1,-6(a0)
  1772.                add.w d1,-2(a0)
  1773.                bra \SK3
  1774. \SK1:          cmp.w #LengthUnequal,ErrorFlag
  1775.                beq \SK7                 ;no end correction required
  1776.                move.w d2,d0             ;Sync value
  1777.                move.l EndPos,a1
  1778.                add.l #2,a1              ;set Pointer to Sync
  1779.                bra \SK4
  1780. \SK6:          cmp.w #$4489,(a1)+       ;test transition to beginning 
  1781.                bne \SK5
  1782. \SK4:          dbf d0,\SK6
  1783. \SK7:          movem.l (a7)+,d2-d4
  1784.                rts
  1785. \SK5:          sub.w d0,d2
  1786.                lsl.w #1,d2
  1787.                sub.l #2,EndPos
  1788.                sub.w #2,TrackBytes
  1789.                sub.w #2,-2(a0)          ;Last Block is shorter
  1790.                bra \SK7
  1791.  
  1792. ;after the Gap has been determined, the Data are copied
  1793. ;and written 
  1794. ;>= A5 = TrackBuffer (Source)
  1795. ;>= A4 = TrackBuffer (Destination)
  1796.  
  1797. Entirecopy:
  1798.                move.l a2,-(a7)
  1799.                move.l a4,a1
  1800.                move.l BegPos,a0
  1801.                sub.l a5,a0              ;Offset of the beginning 
  1802.                clr.l d0
  1803.                move.w Syncwidth,d0
  1804.                sub.w #$0044,d0          ;distance correction 
  1805.                bcc \UK6                 ;distance too small ?
  1806.                clr.w d0                 ;yes, distance = 0
  1807. \UK6:
  1808.                add.l d0,a0              ;distance from Index
  1809.                move.w a0,Offset         ;number of Bytes before Sync
  1810.                suba.l a0,a1             ;beginning of writing 
  1811.                move.l a1,WriteAddrs
  1812.                move.w TrackBytes,d0
  1813.                lsr.w #1,d0              ;Byte to Word
  1814.                move.w LenghtDest,d1
  1815.                move.l BegPos,a0         ;Source-Address 
  1816.                move.l a4,a1             ;Destination-Address
  1817.                cmp.b #ON,AmigaTrack
  1818.                bne \UK9
  1819.                add.l #4,a1
  1820. \UK9:          move.l #$aaaaaaaa,-4(a1)
  1821. \UK4:          move.w (a0),(a1)+
  1822.                sub.w #1,d1
  1823.                cmp.l EndPos,a0
  1824.                bcs \UK3
  1825.                move.l a5,a0
  1826.                bra \UK5
  1827. \UK3:          adda.l #2,a0
  1828. \UK5:          dbf d0,\UK4
  1829.                move.l (a7)+,a2
  1830.                and.w #$f000,d1
  1831.                bne \UK8              ;Source longer than Destination 
  1832. \UK7:          move.w #$aaaa,(a1)+   ;if Dest. is longer than Source
  1833.                dbf d1,\UK7
  1834. \UK8:          move.w LenghtDest,d0
  1835.                sub.w #$0006,d0
  1836.                add.w Offset,d0
  1837.                move.w d0,SLength
  1838.                rts
  1839. ;read Track and decode 
  1840. ;>= A4 = Pointer to Buffer for decoded Data
  1841. ;>= A5 = Pointer to Buffer for coded Data
  1842.  
  1843. FastReads:
  1844.                MOVEM.L D2-D4/a3/a6,-(A7)
  1845.                lea decode,a3             ;Jump point for decode
  1846.                move.w #$080,DecodeCnt    ;number of 
  1847.                                          ;Longwords to decode 
  1848.                lea $40(a5),a0
  1849.                move.l a0,DecodeAdr       ;Data area of first Block
  1850.                adda.l #$400,a0
  1851.                move.l a0,FTestAdr        ;Address of the next Block
  1852.                move.w #OFF,VerifyFlag
  1853.                bra Fread
  1854.  
  1855. FastVerify:    movem.l d2-d4/a3/a6,-(a7)
  1856.                lea FVerify,a3            ;Jump point for Verify
  1857.                move.l a5,DecodeAdr
  1858.                lea $440(a5),a0
  1859.                move.l a0,FTestAdr
  1860.                move.w #ON,VerifyFlag
  1861.  
  1862. Fread:
  1863.                clr.w ErrorFlag
  1864.                bsr DiskInFloppy
  1865.                tst.l d0
  1866.                bmi \FastError
  1867.                MOVEA.L A5,A6             ;Track-Buffer
  1868.                move.l #$aaaaaaaa,(a6)+
  1869.                move.w #$4489,(a6)+       ;enter first Sync 
  1870.                bsr search
  1871.                tst.l d0
  1872.                bmi \FreadEnd
  1873.  
  1874.                bsr FErase                ;prepare Track-Buffer 
  1875.                clr.l d2
  1876.                move.w BytesBefGap,d2     ;display Byte before Gap
  1877.                tst.l d2
  1878.                beq \FL1                  ;No Byte before Gap
  1879.                clr.w BlockAdr            ;Offset in Block
  1880.                bsr Readbyte              ;read Byte 
  1881.                clr.l d0
  1882.                move.w BytesBefGap,d0
  1883.                move.l a5,a6
  1884.                adda.l d0,a6              ;Pointer to next Buffer
  1885.                move.l #$aaaaaaaa,(a6)+
  1886.                move.w #$4489,(a6)+       ;enter first Sync 
  1887. \FL1:          move.w BytesAftGAp,d2
  1888.                tst.l d2
  1889.                beq \FL2
  1890.                clr.w BlockAdr
  1891.                bsr Readbyte
  1892. \FL2:          cmp.w #ON,VerifyFlag
  1893.                beq \FL3
  1894.                bsr lastblock     ;no last Block during Verify
  1895. \FL3:          BTST #2,$BFE001
  1896.                BEQ.S \FastError          ;Error, if no Disk
  1897.                MOVEQ #0,d0               ;OK-Message 
  1898.                move.l #$aaaaaaaa,$2ec0(a5)
  1899.                                          ;create Gap after Data
  1900.                bra \FreadEnd
  1901. \FastError:   move.l #-1,d0
  1902. \FreadEnd:    MOVEM.L (A7)+,D2-D4/a3/A6
  1903.                RTS
  1904.  
  1905. ;prepare Track-Buffer (erase Block starts)
  1906. ;>= A5 = Pointer to Track-Buffer
  1907.  
  1908. FErase:        move.l a5,a0
  1909.                move.w #10,d1
  1910.                clr.l d0
  1911. \L1:           move.l d0,$440(a0)
  1912.                adda.l #$440,a0
  1913.                dbf d1,\L1
  1914.                lea BlockMessage,a0
  1915.                move.w #10,d1
  1916. \L2:           clr.w (a0)+
  1917.                dbf d1,\L2
  1918.                rts
  1919.  
  1920. ;read number of Bytes selected 
  1921. ;>= A6 = Pointer to Destination
  1922. ;>= D2 = Number of Bytes to be read 
  1923.  
  1924. Readbyte:
  1925.                jsr install
  1926.                MOVE.W D2,D0
  1927.                LSR.W #1,D0
  1928.                ORI.W #$8000,D0
  1929.                add.w #1,d0
  1930.                MOVE.W D0,36(A1)
  1931.                MOVE.W D0,36(A1)
  1932.                jsr (a3)
  1933.                LEA $DFF000,A1
  1934.                MOVE.W #$4000,$24(A1)
  1935.                rts
  1936.  
  1937. ;preparation for reading 
  1938. ;>= A6 Pointer to Track-Buffer
  1939.  
  1940. install:       LEA $DFF000,A1
  1941.                move.w #$4000,$24(a1)     ;reset Disk-Len 
  1942.                move.w #$8400,$9e(a1)     ;switch on Disk-Sync 
  1943.                move.w #$4489,$7e(a1)     ;SYNC-Mark 
  1944.                MOVE.L A6,$20(A1)         ;pass Buffer 
  1945.                move.w #$0002,$dff09c
  1946.                rts
  1947.  
  1948. ;code Longword and store in Buffer 
  1949. ;>= D0 = Longword
  1950. ;>= A0 = Pointer to Buffer
  1951.  
  1952. CodeLWord:     MOVEM.L D2-D3,-(A7)
  1953.                MOVE.L D0,D3
  1954.                LSR.L #1,D0
  1955.                BSR \CH1
  1956.                MOVE.L D3,D0
  1957.                BSR \CH1
  1958.                BSR SetBorders
  1959.                MOVEM.L (A7)+,D2-D3
  1960.                RTS
  1961. \CH1:          ANDI.L #$55555555,D0
  1962.                MOVE.L D0,D2
  1963.                EORI.L #$55555555,D2
  1964.                MOVE.L D2,D1
  1965.                LSL.L #1,D2
  1966.                LSR.L #1,D1
  1967.                BSET #$1F,D1
  1968.                AND.L D2,D1
  1969.                OR.L D1,D0
  1970.                BTST #0,-1(A0)
  1971.                BEQ.S \CH2
  1972.                BCLR #$1F,D0
  1973. \CH2:          MOVE.L D0,(A0)+
  1974.                RTS
  1975. ;set borders properly 
  1976.  
  1977. SetBorders:    MOVE.B (A0),D0
  1978.                BTST #0,-1(A0)
  1979.                BNE.S \CH4
  1980.                BTST #6,D0
  1981.                BNE.S \CH6
  1982.                BSET #7,D0
  1983.                BRA.S \CH5
  1984. \CH4:          BCLR #7,D0
  1985. \CH5:          MOVE.B D0,(A0)
  1986. \CH6:          RTS
  1987.  
  1988. ;determine Checksum for Data area 
  1989. ;>= D1 = number of Bytes (must always be divisible by 4)
  1990. ;>= A0 = Pointer to Buffer
  1991. ;=> D0 = Checksum
  1992.  
  1993. TestSum:       MOVE.L D2,-(A7)
  1994.                LSR.W #2,D1
  1995.                SUBQ.W #1,D1
  1996.                MOVEQ #0,D0
  1997. \PS1:          MOVE.L (A0)+,D2
  1998.                EOR.L D2,D0
  1999.                DBRA D1,\PS1
  2000.                ANDI.L #$55555555,D0
  2001.                MOVE.L (A7)+,D2
  2002.                RTS
  2003.  
  2004. ;decode Block-Header 
  2005. ;>= A0 is Pointer to Header
  2006. ;=> D0 = Header
  2007.  
  2008. Header:        move.l (a0)+,D0
  2009.                move.l (a0)+,D1
  2010.                andi.l #$55555555,d0
  2011.                andi.l #$55555555,d1
  2012.                lsl.l #1,D0
  2013.                or.l D1,D0
  2014.                rts
  2015.  
  2016. ;find first undisturbed Block 
  2017. ;=> A6 = Pointer to Track-Buffer
  2018. ;=> D0 = Null: Block found 
  2019. ;=> BytesBefGap = Number of Bytes before the Gap
  2020. ;=> BytesAftGAp = Number of Bytes after the Gap
  2021.  
  2022. search:
  2023.                movem.l d2-d4,-(a7)
  2024.                move.w #11,d2             ;Number of errors permitted
  2025. \SU1:          bsr install
  2026.                move.w #$8024,d0          ;read $24-Words 
  2027.                MOVE.W D0,$dff024
  2028.                MOVE.W D0,$dff024
  2029.                bsr Blockready            ;wait for Block-Ready 
  2030.                tst.l d0                  ;Error, then D0 = -1
  2031.                bmi \SUError
  2032.  
  2033.                lea 8(a5),a0              ;Pointer to Block-Header
  2034.                moveq #$28,d1             ;number of Long words
  2035.                bsr TestSum               ;Sum for Header
  2036.                move.l d0,d3              ;save Sum 
  2037.                lea 48(a5),a0             ;*Sum
  2038.                bsr Header                ;get Sum from Header 
  2039.                cmp.l d0,d3               ;compare Sums 
  2040.                bne \SUNeu
  2041.                lea 8(a5),a0
  2042.                jsr Header                ;decode Header 
  2043.                move.w d0,d3              ;Header to D3
  2044.                lsr.w #8,d3
  2045.                andi.w #$00ff,d3          ;isolate Sector number 
  2046.                addi.w #1,d3              ;increment Sector number 
  2047.                cmp.w #$000a,d3           ;Number bigger than 10?
  2048.                bls \SU2                  ;No, OK
  2049.                clr.w d3                  ;Number = 0
  2050. \SU2:          move.w d3,SectNum         ;store Number 
  2051.                move.w d3,FirstBlock      ;Number first Block
  2052.  
  2053.                move.w d0,d3              ;Header
  2054.                andi.w #$ff,d3            ;Sectors to Gap
  2055.                cmp.b #$0c,d3             ;Header OK?
  2056.                bcs.s \SUok
  2057. \SUNeu:        dbf d2,\SU1
  2058.                bra \SUError
  2059. \SUok:
  2060.  
  2061.                sub.w #1,d3               ;number of Blocks to Gap
  2062.                move.w d3,d2
  2063.                move.w #$000b,d4
  2064.                sub.b d2,d4               ;Number of Blocks after Gap
  2065.                mulu #$440,d3             ;Number of Bytes to Gap
  2066.                mulu #$440,d4             ;Number of Bytes after Gap
  2067.                clr.l d0
  2068.                move.w d3,BytesBefGap
  2069.                move.w d4,BytesAftGAp
  2070.                move.w #$0b,SectBL   ;Sectors before Gap after loading 
  2071.                bra \SUEnd
  2072. \SUError:      move.l #-1,d0
  2073.                move.w #ReadError,ErrorFlag
  2074. \SUEnd:        movem.l (a7)+,d2-d4
  2075.                rts
  2076.  
  2077. Blockready:    clr.l d0                  ;erase Error-Flag 
  2078.                move.l #$20000,d1
  2079.                move.w #$0002,$dff09c     ;erase Disk-Int. 
  2080. \B1:           MOVE.W $DFF01E,D0
  2081.                BTST #1,D0
  2082.                bne.s \B2
  2083.                sub.l #1,d1
  2084.                bne \B1
  2085.                move.l #-1,d0             ;Error occurred 
  2086. \B2:           RTS
  2087.  
  2088.  
  2089. ;decode Bytes until Block has been read 
  2090.  
  2091. decode:
  2092.                movem.l d2-d3/a2,-(a7)
  2093.                clr.l d3
  2094.                move.w BlockAdr,d3        ;Offset in Block
  2095.                move.l FTestAdr,a0        ;Address for testing if 
  2096.                                          ;Block already loaded 
  2097.                move.l DecodeAdr,a2       ;Address where 
  2098.                                          ;decoding is done 
  2099.                move.w DecodeCnt,d2       ;Number for decoding 
  2100.  
  2101. \DC1:          MOVE.W $DFF01E,D0
  2102.                BTST #1,D0                ;area already read 
  2103.                bne  \DCEnd               ;Yes, End
  2104.                tst.l (a0)                ;TestAdr
  2105.                beq \DC1                  ;wait until Block has been read
  2106.  
  2107.                movem.l a0-a1,-(a7)       ;save Register 
  2108.                lea -$40(a2),a1           ;* Block start 
  2109.                bsr BlockCheck            ;check Block 
  2110.                movem.l (a7)+,a0-a1       ;restore Register 
  2111.                move.w SectNum,d0
  2112.                mulu #$200,d0
  2113.                move.l a4,a1              ;Base address for destination data
  2114.                add.l d0,a1               ;Address of the Block
  2115. \DC2:
  2116.                MOVE.W $DFF01E,D0
  2117.                BTST #1,D0
  2118.                bne.s \DCEnd              ;area already read 
  2119.  
  2120.                move.l (a2),D0
  2121.                move.l $200(a2),D1
  2122.                adda.l #4,a2
  2123.                andi.l #$55555555,d0
  2124.                andi.l #$55555555,d1
  2125.                lsl.l #1,D0
  2126.                or.l D1,D0
  2127.                move.l d0,(a1,d3)         ;enter Longword 
  2128.                addq.w #4,d3
  2129.                subq.w #1,D2              ;Decode number 
  2130.                bne \DC2
  2131.                adda.l #$240,a2           ;increment Address
  2132.                adda.l #$440,a0           ;TestAdr
  2133.                move.l #$080,D2           ;Decode number 
  2134.                clr.w d3                  ;Offset to Null
  2135.                add.w #1,SectNum          ;increment Sector number 
  2136.                cmp.w #$0b,SectNum        ;Number more than 10?
  2137.                bcs \DC3                  ;No, OK
  2138.                clr.w SectNum             ;Nummer = 0
  2139. \DC3:          bra \DC1
  2140.  
  2141. \DCEnd:
  2142.                move.w d3,BlockAdr
  2143.                move.l a2,DecodeAdr
  2144.                move.l a0,FTestAdr
  2145.                move.w D2,DecodeCnt
  2146.  
  2147.                movem.l (a7)+,d2-d3/a2
  2148.                RTS
  2149.  
  2150. ;decode last Block 
  2151.  
  2152. Lastblock:
  2153.                movem.l d2-d3/a2,-(a7)
  2154.  
  2155.                move.w SectNum,d0
  2156.                mulu #$200,d0
  2157.                move.l a4,a1            ;Base address for destination data
  2158.                add.l d0,a1             ;Address of the Block
  2159.                clr.l d3
  2160.                move.l DecodeAdr,a2
  2161.                move.w DecodeCnt,d2
  2162. \LB1:          move.l (a2),D0
  2163.                move.l $200(a2),D1
  2164.                adda.l #4,a2
  2165.                andi.l #$55555555,d0
  2166.                andi.l #$55555555,d1
  2167.                lsl.l #1,D0
  2168.                or.l D1,D0
  2169.                move.l d0,(a1,d3)
  2170.                addq.w #$4,d3
  2171.                subq.w #1,D2               ;Decode number 
  2172.                bne \LB1
  2173.                movem.l (a7)+,d2-d3/a2
  2174.                               RTS
  2175.  
  2176. ;test Block for Error 
  2177. ;A1 = Pointer to start of Block 
  2178.  
  2179. BlockCheck:
  2180.                movem.l d2-d3,-(a7)
  2181.                clr.l d3
  2182.                move.w SectNum,d3
  2183.                lsl.w #1,d3               ;Sector number => Offset
  2184.                lea BlockMessage,a0
  2185.                move.w (a0,d3),d0         ;get entry 
  2186.                tst.w d0                  ;already tested ?
  2187.                bne \CBEnd2               ;yes, End
  2188.  
  2189.                lea 64(a1),a0
  2190.                move.w #$400,d1
  2191.                jsr TestSum               ;Sum for Data block
  2192.                move.l d0,d2              ;save Sum 
  2193.                lea 56(a1),a0             ;Pointer to Data sum 
  2194.                jsr Header                ;decode Sum 
  2195.                cmp.l d0,d2
  2196.                bne \DataFalse
  2197.  
  2198.                lea 8(a1),a0
  2199.                bsr Header                ;decode Header 
  2200.                move.w d0,d2              ;store lower Word 
  2201.                lsr.w #8,d2               ;Sector number to d2
  2202.                cmp.b SectNum+1,d2        ;right Sector
  2203.                bne \FalseSector
  2204.                swap d0                   ;Track-Number to D0
  2205.                cmp.b StartTrack+1,d0     ;right Track?
  2206.                bne \FalseTrack
  2207.                andi.l #$ff00,d0
  2208.                cmp.w #$ff00,d0
  2209.                bne \NotDOSTrack
  2210.                lea 8(a1),a0
  2211.                moveq #$28,d1             ;number of Longwords 
  2212.                bsr TestSum               ;Sum for Header
  2213.                move.l d0,d2              ;save Sum 
  2214.                lea 48(a1),a0             ;*Sum 
  2215.                bsr Header                ;get Sum from Header 
  2216.                cmp.l d0,d2               ;compare Sums 
  2217.                bne \HeaderFalse
  2218.                move.w #$ffff,d0
  2219. \CBEnd1:       lea BlockMessage,a0
  2220.                move.w d0,(a0,d3)
  2221.                btst #0,-1(a1)
  2222.                beq \CB1
  2223.                move.l #$2aaaaaaa,(a1)
  2224.                bra \CB2
  2225. \CB1:          move.l #$aaaaaaaa,(a1)
  2226. \CB2:          move.l #$44894489,4(a1)
  2227.                move.w #$ff00,d0          ;create new Header 
  2228.                move.b StartTrack+1,d0
  2229.                swap d0
  2230.                move.b SectNum+1,d0
  2231.                lsl.w #8,d0
  2232.                move.b SectBL+1,d0
  2233.                lea 8(a1),a0
  2234.                bsr CodeLWord             ;store Header 
  2235.                lea 8(a1),a0
  2236.                moveq #$28,d1             ;Longword number 
  2237.                bsr TestSum               ;Sum for Header
  2238.                lea 48(a1),a0             ;*Sum 
  2239.                bsr CodeLWord             ;store Checksum 
  2240.                subq.w #1,SectBL
  2241. \CBEnd2:       movem.l (a7)+,d2-d3
  2242.                rts
  2243.  
  2244. \FalseSector: move.w #$0001,d0
  2245.                  bra \Flagset
  2246. \FalseTrack:     move.w #$0002,d0
  2247.                  bra \Flagset
  2248. \NotDOSTrack:    move.w #$0017,d0
  2249.                  bra \Flagset
  2250. \HeaderFalse:    move.w #$001b,d0
  2251.                  bra \Flagset
  2252. \DataFalse:      move.w #$0019,d0
  2253. \Flagset:        move.w #ReadError,ErrorFlag
  2254.                  bra \CBEnd1
  2255.  
  2256. ;compare Bytes read with old 
  2257. ;>= A4 = Pointer to Base address of the old Block
  2258.  
  2259. FVerify:
  2260.                cmp #VerifyError,ErrorFlag
  2261.                beq \FVEnd2
  2262.                movem.l d2-d3/a2,-(a7)
  2263.                clr.l d3
  2264.                move.w BlockAdr,d3        ;Offset in Block
  2265.                move.l FTestAdr,a0        ;Address for test if 
  2266.                                          ;Block already loaded  
  2267.                move.l DecodeAdr,a2       ;Address, where comparison 
  2268.                                          ;is made
  2269. \FV1:          MOVE.W $DFF01E,D0
  2270.                BTST #1,D0                ;area already read 
  2271.                bne  \FVEnd               ;Yes, End
  2272.                tst.l (a0)                ;TestAdr
  2273.                beq \FV1                  ;Wait until Block was read
  2274.                move.w #$110,d2           ;comparison number
  2275.                move.w SectNum,d0
  2276.                sub.w FirstBlockSp,d0
  2277.                bcc \FV2
  2278.                addi.w #11,d0
  2279. \FV2:
  2280.                mulu #$440,d0
  2281.                move.l a4,a1            ;Base address for destination data
  2282.                add.l d0,a1             ;Address of the Block
  2283. \FV3:
  2284.                move.l (a2)+,d0
  2285.                cmp.l (a1,d3),d0
  2286.                beq \FV6                 ;Verify Ok
  2287. ;test for special case ($aaaaaaaa and $2aaaaaaa)
  2288.                move.l (a1,d3),d1
  2289.                eor.l d1,d0
  2290.                cmp.l #$80000000,d0
  2291.                bne \FV5
  2292. \FV6:          addq.w #4,d3
  2293.                subq.w #1,d2
  2294.                bne \FV3
  2295.                adda.l #$440,a0           ;TestAdr
  2296.                clr.l d3                  ;Offset to Null
  2297.                add.w #1,SectNum          ;increment Sector number 
  2298.                cmp.w #$0b,SectNum        ;Number higher than 10?
  2299.                bcs \FV1                  ;No, OK
  2300.                clr.w SectNum             ;Number = 0
  2301.                bra \FV1
  2302. \FV5:          move.w #VerifyError,ErrorFlag
  2303.                bra \FVEnd3
  2304. \FVEnd:
  2305.                clr.w ErrorFlag
  2306.                move.w d3,BlockAdr
  2307.                move.l a2,DecodeAdr
  2308.                move.l a0,FTestAdr
  2309. \FVEnd3:       movem.l (a7)+,d2-d3/a2
  2310. \FVEnd2:       RTS
  2311.  
  2312. ;code Track 
  2313. ;>= A0 = Pointer to Source
  2314. ;>= A1 = Pointer to Destination
  2315. ;>= D0 = Track-Number
  2316. CodeTrack:
  2317.                movem.l d2-d4/a2-a3,-(a7)
  2318.                move.l d0,d4
  2319.                move.l a0,a2
  2320.                move.l a1,a3
  2321.                moveq #$0b,d2
  2322.                clr.w d3
  2323. \CT1:          move.w #$ff00,d0
  2324.                move.b d4,d0
  2325.                swap d0
  2326.                move.w d3,d0
  2327.                lsl.w #8,d0
  2328.                move.b d2,d0
  2329.                move.l a2,a0              ;Source
  2330.                move.l a3,a1              ;Destination
  2331.                bsr ConstructBlock
  2332.                add.l #$440,a3
  2333.                add.l #$200,a2
  2334.                addq.w #1,d3
  2335.                subq.w #1,d2
  2336.                bne \CT1
  2337.                movem.l (a7)+,d2-d4/a2-a3
  2338.                rts
  2339.  
  2340. ;code Block and create Header 
  2341. ;>= A0 = Uncoded Data (Source)
  2342. ;>= A1 = Data buffer for coded Data (Destination)
  2343. ;>= D0 = uncoded Header
  2344.  
  2345. ConstructBlock: MOVEM.L D2/A2/A4,-(A7)
  2346.                MOVEA.L A1,A4
  2347.                MOVEA.L A0,A2
  2348.                MOVE.L D0,D2
  2349.                MOVEQ #0,D0
  2350.                LEA 0(A4),A0
  2351.                BSR CodeLWord
  2352.                MOVE.L #$44894489,4(A4)
  2353.                MOVE.L D2,D0
  2354.                LEA 8(A4),A0
  2355.                BSR CodeLWord
  2356.                MOVEQ #3,D2
  2357. \EB1:          MOVEQ #0,D0
  2358.                BSR CodeLWord
  2359.                DBRA D2,\EB1
  2360.                LEA 8(A4),A0
  2361.                MOVEQ #$28,D1
  2362.                BSR TestSum
  2363.                LEA $30(A4),A0
  2364.                BSR CodeLWord
  2365.                MOVE.L #$200,D0
  2366.                MOVEA.L A2,A0
  2367.                LEA $40(A4),A1
  2368.                BSR CodeBlock
  2369.                LEA $40(A4),A0
  2370.                MOVE.W #$400,D1
  2371.                BSR TestSum
  2372.                LEA $38(A4),A0
  2373.                BSR CodeLWord
  2374.                MOVEM.L (A7)+,D2/A2/A4
  2375.                RTS
  2376.  
  2377. ;code Data Block 
  2378. ;>= D0 = Length of the Source
  2379. ;>= A0 = Pointer to Source
  2380. ;>= A1 = Pointer to Destination
  2381.  
  2382. CodeBlock:
  2383.  
  2384.                movem.l  d2/a5,-(a7)
  2385.                MOVE.W D0,D1
  2386.                LSL.W #2,D1
  2387.                ORI.W #8,D1
  2388.                MOVE.W D1,D2
  2389.                movem.l d0-d1/a0-a1/a5,-(a7)
  2390.                move.l a0,d1
  2391.                move.l a1,a5
  2392.                lea $dff000,a0
  2393.                bsr BlitWait
  2394.                bsr BlitterCode
  2395.                movem.l (a7)+,d0-d1/a0-a1/a5
  2396.                MOVE.L D0,D1
  2397.                MOVEA.L A1,A0
  2398.                BSR SetBorders
  2399.                ADDA.L D1,A0
  2400.                BSR SetBorders
  2401.                ADDA.L D1,A0
  2402.                BSR SetBorders
  2403.                movem.l (a7)+,d2/a5
  2404.                RTS
  2405.  
  2406. ;A0 = $dff000
  2407. ;D0 = Length of Source
  2408. ;D1 = Source
  2409. ;A5 = Destination
  2410.  
  2411. BlitterCode:
  2412.                bsr Modulu                ;set Mode 
  2413.                MOVE.L D1,$4C(A0)
  2414.                MOVE.L D1,$50(A0)
  2415.                MOVE.L A5,$54(A0)
  2416.                MOVE.W #$1DB1,$40(A0)
  2417.                MOVE.W #0,$42(A0)
  2418.                bsr StartBlit
  2419.                MOVE.L A5,$4C(A0)         ;Source B
  2420.                MOVE.L D1,$50(A0)         ;Source A
  2421.                MOVE.L A5,$54(A0)         ;Dest
  2422.                MOVE.W #$2d8c,$40(A0)
  2423.                bsr StartBlit
  2424.                movem.l d0-d1/a5,-(a7)
  2425.                ADD.L D0,D1
  2426.                SUBQ.L #2,D1
  2427.                ADDA.L D0,A5
  2428.                ADDA.L D0,A5
  2429.                SUBQ.L #2,A5
  2430.                MOVE.L D1,$4C(A0)
  2431.                MOVE.L D1,$50(A0)
  2432.                MOVE.L A5,$54(A0)
  2433.                MOVE.W #$DB1,$40(A0)
  2434.                MOVE.W #$1002,$42(A0)
  2435.                bsr StartBlit
  2436.                movem.l (a7)+,d0-d1/a5
  2437.                movem.l d0-d1/a5,-(a7)
  2438.                ADDA.L D0,A5
  2439.                MOVE.L A5,$4C(A0)
  2440.                MOVE.L D1,$50(A0)
  2441.                MOVE.L A5,$54(A0)
  2442.                MOVE.W #$1D8C,$40(A0)
  2443.                MOVE.W #0,$42(A0)
  2444.                bsr StartBlit
  2445.                movem.l (a7)+,d0-d1/a5
  2446.                rts
  2447.  
  2448. ;start Blitter and wait for end of Blitter 
  2449.  
  2450. StartBlit:
  2451.                MOVE.W d2,$dff058
  2452. BlitWait:      btst #14,$dff002
  2453.                bne.s BlitWait
  2454.                rts
  2455.  
  2456. ;set Mode for coding 
  2457. ;>= A0 = $dff000
  2458. Modulu:
  2459.                movem.l d0/a1,-(a7)
  2460.                MOVEQ #0,D0
  2461.                LEA $44(A0),A1
  2462.                MOVE.L #-1,(A1)
  2463.                LEA $62(A0),A1
  2464.                MOVE.L D0,(A1)+
  2465.                MOVE.W D0,(A1)+
  2466.                ADDQ.L #8,A1
  2467.                MOVE.W #$5555,(A1)
  2468.                movem.l (a7)+,d0/a1
  2469.                rts
  2470.  
  2471. ;erase Track with DOS 
  2472. ;>= A0 = Pointer to Track-Buffer
  2473. DOSClear:
  2474.                move.l #$444F5300,d0      ;DOS + 0
  2475.                move.w #$57f,d1
  2476. \DO1:          move.l d0,(a0)+           ;erase Track 
  2477.                addq.b #1,d0
  2478.                dbf d1,\DO1
  2479.                rts
  2480.  
  2481. ;shorten Track and store in memory 
  2482. ;>= A0 = Pointer to beginning of Track
  2483. ;>= A1 = Pointer to destination address
  2484. ;>= Length = number of Bytes to be shortened
  2485. ;>= ShrtByte = Byte, which should be stored shorter 
  2486. ;=> A1 = Pointer to memory for shortened Block
  2487.  
  2488. Crunch:
  2489.                movem.l d2-d7/a2/a4,-(a7)
  2490.                clr.w d7
  2491.                clr.w d2
  2492.                move.w Length,d3      ;number of Bytes
  2493.                move.l MemoryLength,d6
  2494. \CHAnf:
  2495.                tst.w d7
  2496.                bne \CHEnd
  2497.                movea.l a0,a2         ;intermediate storage for Address 
  2498. \CH4:          bsr \EraseBlock
  2499.                tst.w d0
  2500.                beq \CHAnf
  2501.                move.b (a0),d4
  2502.                cmp.b ShrtByte,d4
  2503.                beq \KF1                  ;Null byte
  2504.                cmp.b 1(a0),d4
  2505.                bne \CH10                 ;no sequel 
  2506.                cmp.b 2(a0),d4
  2507.                beq \AF1                  ;other sequels 
  2508. \CH10:         addq.l #1,a0
  2509.                subq.w #1,d3
  2510.                bne \CH4                  ;continue search 
  2511.                bsr \NoResult
  2512. \CHEnd:
  2513.                move.b #$00,d0
  2514.                move.b d0,(a1)+
  2515.                subq.l #1,d6
  2516.                bcs CrunEnd
  2517.                move.l d6,MemoryLength
  2518.                move.l a1,MemoryBeg
  2519.                clr.l d0
  2520.                movem.l (a7)+,d2-d7/a2/a4
  2521.                rts
  2522. ;short sequel 
  2523.  
  2524. \KF1:          cmp.b 1(a0),d4
  2525.                bne \CH10                 ;no Null 
  2526.                bsr \NoResult
  2527.                bsr CounterBytes
  2528.                cmp.w #$40,d1
  2529.                bcc \KF2                  ;too large for a Byte
  2530.                ori.b #ShrtNull,d1
  2531.                move.b d1,(a1)+
  2532.                subq.l #1,d6
  2533.                beq CrunEnd
  2534.                bra \KF4
  2535. \KF2:          cmp.w #$1000,d1
  2536.                bcc \KF3                  ;too large, must be Word
  2537.                move.w d1,d0
  2538.                lsr.w #8,d0
  2539.                ori.b #MiddleNull,d0      ;Null sequence with Byte
  2540.                move.b d0,(a1)+
  2541.                subq.l #1,d6
  2542.                beq CrunEnd
  2543.                move.b d1,(a1)+
  2544.                subq.l #1,d6
  2545.                beq CrunEnd
  2546.                bra \KF4
  2547. \KF3:          move.b #LongNull,d0
  2548.                move.b d0,(a1)+
  2549.                subq.l #1,d6
  2550.                beq CrunEnd
  2551.                move.w d1,d0
  2552.                lsr.w #8,d0
  2553.                move.b d0,(a1)+
  2554.                subq.l #1,d6
  2555.                beq CrunEnd
  2556.                move.b d1,(a1)+
  2557.                subq.l #1,d6
  2558.                beq CrunEnd
  2559. \KF4:          bra \CHAnf
  2560.  
  2561. ;other sequence 
  2562.  
  2563. \AF1:          bsr \NoResult
  2564.                bsr CounterBytes
  2565.                cmp.w #$40,d1
  2566.                bcc \AF2                  ;too large for a Byte
  2567.                ori.b #ShrtNorm,d1
  2568.                move.b d1,(a1)+
  2569.                subq.l #1,d6
  2570.                beq CrunEnd
  2571.                bra \AF4
  2572. \AF2:          cmp.w #$1000,d1
  2573.                bcc \AF3                  ;too large, must be Word
  2574.                move.w d1,d0
  2575.                lsr.w #8,d0
  2576.                ori.b #MiddleNorm,d0      ;any sequence 
  2577.                                          ;Byte
  2578.                move.b d0,(a1)+
  2579.                subq.l #1,d6
  2580.                beq CrunEnd
  2581.                move.b d1,(a1)+
  2582.                subq.l #1,d6
  2583.                beq CrunEnd
  2584.                bra \AF4
  2585. \AF3:          move.b #LongNorm,d0
  2586.                move.b d0,(a1)+
  2587.                subq.l #1,d6
  2588.                beq CrunEnd
  2589.                move.w d1,d0
  2590.                lsr.w #8,d0
  2591.                move.b d0,(a1)+
  2592.                subq.l #1,d6
  2593.                beq CrunEnd
  2594.                move.b d1,(a1)+
  2595.                subq.l #1,d6
  2596.                beq CrunEnd
  2597. \AF4:          move.b d4,d0              ;store other Byte 
  2598.                move.b d0,(a1)+
  2599.                subq.l #1,d6
  2600.                beq CrunEnd
  2601.                bra \CHAnf
  2602.  
  2603. ;found no sequence 
  2604. \NoResult2:  move.w #1,Subtr             ;See CrunEnd2
  2605.                bra \KF20
  2606. \NoResult:   clr.w Subtr
  2607. \KF20:         move.l a0,a4
  2608.                sub.l a2,a4
  2609.                move.w a4,d1
  2610.                beq \KFEnd
  2611.                swap d1
  2612.                move.w a4,d1
  2613.                cmp.w #$40,d1
  2614.                bcc \CH5                  ;too large for a Byte
  2615.                ori.b #ShrtNone,d1
  2616.                move.b d1,(a1)+
  2617.                subq.l #1,d6
  2618.                beq CrunEnd2
  2619.                bra \CH6
  2620. \CH5:          cmp.w #$1000,d1
  2621.                bcc \CH7                  ;too large, must be Word
  2622.                move.w d1,d0
  2623.                lsr.w #8,d0
  2624.                ori.b #MiddleNone,d0
  2625.                move.b d0,(a1)+
  2626.                subq.l #1,d6
  2627.                beq CrunEnd2
  2628.                move.b d1,(a1)+
  2629.                subq.l #1,d6
  2630.                beq CrunEnd2
  2631.                bra \CH6
  2632. \CH7:          move.b #LongNone,D0
  2633.                move.b d0,(a1)+
  2634.                subq.l #1,d6
  2635.                beq CrunEnd2
  2636.                move.w d1,d0
  2637.                lsr.w #8,d0
  2638.                move.b d0,(a1)+
  2639.                subq.l #1,d6
  2640.                beq CrunEnd2
  2641.                move.b d1,(a1)+
  2642.                subq.l #1,d6
  2643.                beq CrunEnd2
  2644. \CH6:          swap d1
  2645.                andi.l #$ffff,d1
  2646.                sub.l d1,d6
  2647.                beq CrunEnd2
  2648.                bcs CrunEnd2
  2649.                bra \CH8
  2650. \CH9:          move.b (a2)+,(a1)+
  2651. \CH8:          dbf d1,\CH9
  2652. \KFEnd:        clr.w Subtr               ;See CrunEnd2
  2653.                rts
  2654.  
  2655. \EraseBlock:
  2656.                move.w d3,d0
  2657.                andi.w #$fe00,d0
  2658.                cmp.w d0,d3
  2659.                bne \LBEnd2
  2660.                move.l a0,a3
  2661.                move.w #$7e,d5
  2662.                move.l (a0)+,d4
  2663.                move.l d4,d0
  2664.                andi.l #$ff000000,d0
  2665.                cmp.l #$44000000,d0
  2666.                bne \LBNone
  2667. \LB1:          addq.b #1,d4
  2668.                cmp.l (a0)+,d4
  2669.                bne \LBNone
  2670.                dbf d5,\LB1
  2671.                bsr \NoResult2
  2672.                move.b #EmptyBlock,d0
  2673.                move.b d0,(a1)+
  2674.                subq.l #1,d6
  2675.                beq CrunEnd2
  2676.                clr.w d0                  ;Ok-Message 
  2677.                subi.w #$200,d3
  2678.                bne \LBEnd
  2679.                move.w #-1,d7             ;End mark 
  2680.                bra \LBEnd
  2681. \LBNone:       move.l a3,a0
  2682. \LBEnd2:       move.w #-1,d0
  2683. \LBEnd:        rts
  2684.  
  2685. CounterBytes:    clr.w d1
  2686. \ZB2:          cmp.b (a0)+,d4
  2687.                bne \ZB1
  2688.                addq.w #1,d1
  2689.                subq.w #1,d3
  2690.                bne \ZB2
  2691.                move.w #-1,d7             ;End mark 
  2692. \ZB1:
  2693.                subq.l #1,a0
  2694.                rts
  2695.  
  2696.  
  2697.  
  2698. CrunEnd2:      move.w Subtr,d2
  2699. \CE1:          adda.l #$4,a7
  2700.                dbf d2,\CE1
  2701. CrunEnd:
  2702.                movem.l (a7)+,d2-d7/a2/a4
  2703.                move.l #-1,d0
  2704.                rts
  2705.  
  2706. ;bring Track to normal size 
  2707. ;>= A0 = Pointer to crunched Track
  2708. ;>= A1 = Pointer to destination address
  2709.  
  2710. DeCrunch:
  2711.                move.b (a0)+,d0
  2712.                tst.b d0
  2713.                beq \DCEnd                ;End mark 
  2714.                move.b d0,d1
  2715.                andi.b #$c0,d1
  2716.                bne Shrt
  2717.                move.b d0,d1
  2718.                andi.b #$30,d1
  2719.                bne Middle
  2720.                move.b d0,d1
  2721.                cmpi.b #EmptyBlock,d1
  2722.                beq \BlockClear
  2723.                move.b (a0)+,d0
  2724.                lsl.w #8,d0
  2725.                move.b (a0)+,d0
  2726.                cmpi.b #LongNull,d1
  2727.                beq \NullLong
  2728.                cmpi.b #LongNorm,d1
  2729.                beq \NormLong
  2730.                cmpi.b #LongNone,d1
  2731.                beq \UndefLong
  2732. ;error 
  2733.                move.l $4,a6
  2734.                sub.l a5,a5
  2735.                move.l #$12345678,d7
  2736.                jsr -108(a6)
  2737. \DCEnd:        rts
  2738.  
  2739.  
  2740. ;empty Block
  2741. \BlockClear:    move.w #$7f,d1
  2742.                move.l #$444F5300,d0
  2743. \LB1:          move.l d0,(a1)+
  2744.                addq.b #1,d0
  2745.                dbf d1,\LB1
  2746.                bra DeCrunch
  2747. ;Long 
  2748.  
  2749. \LA1:          move.b (a0)+,(a1)+
  2750. \UndefLong:    dbf d0,\LA1
  2751.                bra DeCrunch
  2752. \NullLong:     move.b Shrtbyte,d1
  2753.                bra \LA2
  2754. \NormLong:     move.b (a0)+,d1
  2755.                bra \LA2
  2756. \LA3:          move.b d1,(a1)+
  2757. \LA2:          dbf d0,\LA3
  2758.                bra DeCrunch
  2759. Shrt:
  2760.                cmpi.b #ShrtNull,d1
  2761.                beq \KU1
  2762.                cmpi.b #ShrtNorm,d1
  2763.                beq \KU2
  2764. ;ShrtUndeff
  2765.                andi.w #$3f,d0
  2766.                bra \KU3
  2767. \KU4:          move.b (a0)+,(a1)+
  2768. \KU3:          dbf d0,\KU4
  2769.                bra DeCrunch
  2770. \KU1:          move.b Shrtbyte,d1
  2771.                bra \KU5
  2772. \KU2:          move.b (a0)+,d1
  2773. \KU5:          andi.w #$003f,d0
  2774.                bra \KU6
  2775. \KU7:          move.b d1,(a1)+
  2776. \KU6:          dbf d0,\Ku7
  2777.                bra DeCrunch
  2778. Middle:
  2779.                andi.w #$0f,d0
  2780.                lsl.w #8,d0
  2781.                move.b (a0)+,d0
  2782.                cmpi.b #MiddleNull,d1
  2783.                beq \KU1
  2784.                cmpi.b #MiddleNorm,d1
  2785.                beq \KU2
  2786. ;MiddleUndeff
  2787.                bra \KU3
  2788. \KU4:          move.b (a0)+,(a1)+
  2789. \KU3:          dbf d0,\KU4
  2790.                bra DeCrunch
  2791. \KU1:          move.b Shrtbyte,d1
  2792.                bra \KU6
  2793. \KU2:          move.b (a0)+,d1
  2794.                bra \KU6
  2795. \KU7:          move.b d1,(a1)+
  2796. \KU6:          dbf d0,\Ku7
  2797.                bra DeCrunch
  2798.  
  2799. beg:
  2800.         move.w #$0008,$dff09a
  2801.  
  2802.         move.l gfxbase,a6
  2803.         lea    bitmap,a0
  2804.         move.b #1,d0
  2805.         move.w #320,d1
  2806.         move.w #200,d2         ;PAL uses 256
  2807.         jsr    InitBitMap(a6)
  2808.         move.l bit_adress,plane1
  2809.         move.l bit_adress,d1
  2810.         move.w d1,plane_lo
  2811.         swap   d1
  2812.         move.w d1,plane_hi
  2813.  
  2814.         lea    rastport,a1
  2815.         jsr    InitRastPort(a6)
  2816.         move.l #bitmap,r_bitmap
  2817.  
  2818.         move.l #ncopper,a0
  2819.         move.l cop_adress,a1
  2820.         move.l #copsize,d0
  2821. copy_loop:
  2822.         move.b (a0)+,(a1)+
  2823.         dbf    d0,copy_loop
  2824.  
  2825.         bsr  adresses
  2826.         move.l c1_adress,flash_adress
  2827.  
  2828.         move.l bit_adress,a0
  2829.         move.w #$27ff,d0
  2830. clear_loop:
  2831.         clr.b  (a0)+
  2832.         dbf    d0,clear_loop
  2833.  
  2834.         move.l gfxbase,a0
  2835.         move.w #$0080,$dff096
  2836.         move.l $6c,oldirq
  2837.         move.l #newirq,$6c
  2838.         move.l 50(a0),oldcopper
  2839.         move.l cop_adress,50(a0)
  2840.         move.w #$82b0,$dff096
  2841.  
  2842. new_start:
  2843.         move.w #7,x1
  2844.         move.w #54,y1
  2845.         move.b #$4f,lc
  2846.         move.b #$00,fc
  2847.         move.b #$03,tr
  2848.         move.b #$00,ws
  2849.         move.b #$01,vd
  2850.         move.b #$01,fa
  2851.         move.b #$00,dc1
  2852.         move.b #$00,dc2
  2853.         move.b #$01,sd
  2854.         move.b #$00,dd
  2855.         move.b #$01,sy
  2856.         move.b #$00,new
  2857.         move.b #$00,pointer1
  2858.         move.b #$00,color_ptr
  2859.         move.b drives,dd
  2860.         bsr  end_drive
  2861.         bsr  show_lc
  2862.         move.l #text1,text_ptr
  2863.         bsr  set_title
  2864.         bra  menu_control
  2865. exit:
  2866.         move.w #$8008,$dff09a
  2867.         move.l gfxbase,a0
  2868.         move.w #$0080,$dff096
  2869.         move.l oldirq,$6c
  2870.         move.l oldcopper,50(a0)
  2871.         move.w #$82b0,$dff096
  2872.  
  2873. no_DPuffer:
  2874.         move.l ExecBase,a6
  2875.         move.l cop_adress,a1
  2876.         move.l #copsize+2,d0
  2877.         jsr    FreeMem(a6)
  2878. no_copper:
  2879.         move.l ExecBase,a6
  2880.         move.l bit_adress,a1
  2881.         move.l #$2800,d0
  2882.         jsr    FreeMem(a6)
  2883. no_bitmap:
  2884.         move.l ExecBase,a6
  2885.         move.l gfxbase,a1
  2886.         jsr    CloseLibrary(a6)
  2887. no_gfxbase:
  2888.         clr.l  d0
  2889.         rts
  2890.  
  2891. newirq:
  2892.         move   SR,-(a7)
  2893.         movem.l a0-a6/d0-d7,-(a7)
  2894.         addq.b #1,waiting
  2895.         cmp.b  #2,waiting
  2896.         ble    endirq
  2897.         clr.b  waiting
  2898.         move.l flash_adress,a2
  2899.         cmpi.b #$00,color_ptr
  2900.         bne.s  irq_flash
  2901.         move.w #$00ee,(a2)
  2902.         bra.s  endirq
  2903. irq_flash:
  2904.         cmpi.b #$00,back
  2905.         beq.s  upward
  2906. downward:
  2907.         subi.w #$0011,(a2)
  2908.         cmpi.w #$0044,(a2)
  2909.         bcc.s  endirq
  2910.         move.b #$00,back
  2911.         bra.s  endirq
  2912. upward: addi.w #$0011,(a2)
  2913.         cmpi.w #$00ff,(a2)
  2914.         bcs.s  endirq
  2915.         move.b #$01,back
  2916. endirq: movem.l (a7)+,a0-a6/d0-d7
  2917.         move   (a7)+,SR
  2918.         dc.w $4ef9
  2919. oldirq: dc.l 0
  2920.  
  2921. menu_control:
  2922.         bsr  wait_key
  2923.         cmpi.b #$46,d0
  2924.         beq  destination_drive
  2925.         cmpi.b #$50,d0
  2926.         beq  start_copy
  2927.         cmpi.b #$51,d0
  2928.         beq  first_cylinder
  2929.         cmpi.b #$52,d0
  2930.         beq  last_cylinder
  2931.         cmpi.b #$53,d0
  2932.         beq  how_many_tries
  2933.         cmpi.b #$54,d0
  2934.         beq  write_serveral_times
  2935.         cmpi.b #$55,d0
  2936.         beq  verify_destination
  2937.         cmpi.b #$56,d0
  2938.         beq  fast_copy
  2939.         cmpi.b #$57,d0
  2940.         beq  deepcopy_1
  2941.         cmpi.b #$58,d0
  2942.         beq  deepcopy_2
  2943.         cmpi.b #$59,d0
  2944.         beq  source_drive
  2945.         cmpi.b #$21,d0
  2946.         beq  synccorrection
  2947.         bra.s  menu_control
  2948. start_copy:
  2949.         move.l c2_adress,flash_adress
  2950.         move.b #$01,color_ptr
  2951.         bsr  show_start
  2952. start_copy2:
  2953.         bsr  wait_key
  2954.         cmpi.b #$45,d0
  2955.         beq  new_start
  2956.         cmpi.b #$44,d0                   ;Return
  2957.         beq.s  end_start
  2958.         cmpi.b #$43,d0
  2959.         bne.s  start_copy2
  2960. end_start:
  2961.         move.b #$00,color_ptr
  2962.         move.w #28,y1
  2963.         bsr    cl2
  2964.         move.w #10,d0
  2965. estlop: bsr    Timer
  2966.         dbf    d0,estlop
  2967.         bsr clear_eol
  2968.         bsr copy_start                   ;Copy-Routine
  2969.         cmp.w #Escape,ErrorFlag
  2970.         beq new_start
  2971.         cmp.w #diskprotect,errorflag
  2972.         beq start_copy
  2973.         cmp.w #NoDisk,errorflag
  2974.         beq start_copy
  2975.         cmp.w #NotProtect,ErrorFlag
  2976.         beq.s start_copy
  2977.         bsr  cl1
  2978. esd1:   bsr  wait_key
  2979.         cmpi.b #$40,d0
  2980.         bne.s  esd1
  2981. esd2:   bra new_start
  2982.  
  2983. destination_drive:
  2984.         move.l c13_adress,flash_adress
  2985.         move.b #$01,color_ptr
  2986. destination1:
  2987.         bsr  wait_key
  2988.         cmpi.b #$0a,d0
  2989.         beq.s  d_drive0
  2990.         cmpi.b #$01,d0
  2991.         beq.s  d_drive1
  2992.         cmpi.b #$02,d0
  2993.         beq  d_drive2
  2994.         cmpi.b #$03,d0
  2995.         beq  d_drive3
  2996.         cmpi.b #$43,d0
  2997.         beq.s  end_destination
  2998.         cmpi.b #$44,d0
  2999.         bne.s  destination1
  3000. end_destination:
  3001.         cmpi.b #$00,dd
  3002.         beq.s  destination1
  3003.         move.b #$00,color_ptr
  3004.         bra  menu_control
  3005. d_drive0:
  3006.         btst   #0,drives
  3007.         beq  end_drive
  3008.         btst   #0,dd
  3009.         beq.s  dd0_0
  3010.         bclr   #0,dd
  3011.         bra.s  dd0_1
  3012. dd0_0:  bset   #0,dd
  3013.         move.b #1,drv
  3014. dd0_1:  bra  end_drive
  3015.  
  3016. d_drive1:
  3017.         btst   #1,drives
  3018.         beq  end_drive
  3019.         btst   #1,dd
  3020.         beq.s  dd1_0
  3021.         bclr   #1,dd
  3022.         bra.s  dd1_1
  3023. dd1_0:  bset   #1,dd
  3024.         move.b #2,drv
  3025. dd1_1:  bra.s  end_drive
  3026.  
  3027. d_drive2:
  3028.         btst   #2,drives
  3029.         beq.s  end_drive
  3030.         btst   #2,dd
  3031.         beq.s  dd2_0
  3032.         bclr   #2,dd
  3033.         bra.s  dd2_1
  3034. dd2_0:  bset   #2,dd
  3035.         move.b #4,drv
  3036. dd2_1:  bra.s  end_drive
  3037.  
  3038. d_drive3:
  3039.         btst   #3,drives
  3040.         beq.s  end_drive
  3041.         btst   #3,dd
  3042.         beq.s  dd3_0
  3043.         bclr   #3,dd
  3044.         bra.s  end_drive
  3045. dd3_0:  bset   #3,dd
  3046.         move.b #8,drv
  3047. end_drive:
  3048.         cmpi.b #$01,dc1
  3049.         bne.s  st1
  3050.         bra.s  st2
  3051. st1:    cmpi.b #$01,dc2
  3052.         bne  steve1
  3053. st2:    move.b drv,dd
  3054.         bra  steve
  3055. steve1: btst   #0,sd
  3056.         beq.s  ste1
  3057.         andi.b #$0e,dd
  3058.         cmpi.b #$00,dd
  3059.         bne.s  steve
  3060.         bset   #0,dd
  3061.         bra.s  steve
  3062. ste1:   btst   #1,sd
  3063.         beq.s  ste2
  3064.         andi.b #$0d,dd
  3065.         cmpi.b #$00,dd
  3066.         bne.s  steve
  3067.         bset   #1,dd
  3068.         bra.s  steve
  3069. ste2:   btst   #2,sd
  3070.         beq.s  ste3
  3071.         andi.b #$0b,dd
  3072.         cmpi.b #$00,dd
  3073.         bne.s  steve
  3074.         bset   #2,dd
  3075.         bra.s  steve
  3076. ste3:   btst   #3,sd
  3077.         beq.s  steve
  3078.         andi.b #$07,dd
  3079.         cmpi.b #$00,dd
  3080.         bne.s  steve
  3081.         bset   #3,dd
  3082. steve:  btst   #0,dd
  3083.         bne.s  end_dd1
  3084.         lea    off_text,a0
  3085.         bra.s  end_dd2
  3086. end_dd1:lea    on_text2,a0
  3087. end_dd2:bsr  set_drive0
  3088.         btst   #1,dd
  3089.         bne.s  end_dd3
  3090.         lea    off_text,a0
  3091.         bra.s  end_dd4
  3092. end_dd3:lea    on_text2,a0
  3093. end_dd4:bsr  set_drive1
  3094.         btst   #2,dd
  3095.         bne.s  end_dd5
  3096.         lea    off_text,a0
  3097.         bra.s  end_dd6
  3098. end_dd5:lea    on_text2,a0
  3099. end_dd6:bsr  set_drive2
  3100.         btst   #3,dd
  3101.         bne.s  end_dd7
  3102.         lea    off_text,a0
  3103.         bra.s  end_dd8
  3104. end_dd7:lea    on_text2,a0
  3105. end_dd8:bsr  set_drive3
  3106.         cmpi.b #$00,pointer1
  3107.         bne.s  end_dd9
  3108.         move.b #$01,pointer1
  3109.         rts
  3110. end_dd9:bra  destination1
  3111.  
  3112. set_drive0:
  3113.         move.l gfxbase,a6
  3114.         lea    rastport,a1
  3115.         move.w #61,d0
  3116.         move.w #190,d1         ;PAL 213
  3117.         jsr    Movee(a6)
  3118.         bra.s  set_text
  3119. set_drive1:
  3120.         move.l gfxbase,a6
  3121.         lea    rastport,a1
  3122.         move.w #126,d0
  3123.         move.w #190,d1         ;PAL 213
  3124.         jsr    Movee(a6)
  3125.         bra.s  set_text
  3126. set_drive2:
  3127.         move.l gfxbase,a6
  3128.         lea    rastport,a1
  3129.         move.w #190,d0
  3130.         move.w #190,d1         ;PAL 213
  3131.         jsr    Movee(a6)
  3132.         bra.s  set_text
  3133. set_drive3:
  3134.         move.l gfxbase,a6
  3135.         lea    rastport,a1
  3136.         move.w #254,d0
  3137.         move.w #190,d1         ;PAL 213
  3138.         jsr    Movee(a6)
  3139. set_text:
  3140.         lea    rastport,a1
  3141.         move.w #$0003,d0
  3142.         jsr    Textout(a6)
  3143.         rts
  3144.  
  3145. first_cylinder:
  3146.         move.l c3_adress,flash_adress
  3147.         move.b #$01,color_ptr
  3148.         bsr  wait_key
  3149.         cmpi.b #$4f,d0
  3150.         beq.s  fc_down
  3151.         cmpi.b #$4e,d0
  3152.         beq.s  fc_up
  3153.         cmpi.b #$43,d0
  3154.         beq  compare_fc
  3155.         cmpi.b #$44,d0
  3156.         bne.s  first_cylinder
  3157. compare_fc:
  3158.         move.b lc,d0
  3159.         cmp.b fc,d0
  3160.         beq  compare_fc2
  3161.         blt.s  first_cylinder
  3162. compare_fc2:
  3163.         move.b #$00,color_ptr
  3164.         bra  menu_control
  3165. fc_down:subi.b #$01,fc
  3166.         cmpi.b #$ff,fc
  3167.         bne.s  fc_down2
  3168.         move.b #$00,fc
  3169. fc_down2:
  3170.         bra  show_fc
  3171. fc_up:  addi.b #$01,fc
  3172.         cmpi.b #$52,fc
  3173.         bne.s  fc_down2
  3174.         move.b #$51,fc
  3175. show_fc:lea    fc_text,a0
  3176.         move.b fc,d0
  3177.         bsr  byte_calculate
  3178.         move.l gfxbase,a6
  3179.         lea    rastport,a1
  3180.         move.w #295,d0
  3181.         move.w #64,d1
  3182.         jsr    Movee(a6)
  3183.         lea    rastport,a1
  3184.         lea    fc_text,a0
  3185.         move.w #$0002,d0
  3186.         jsr    Textout(a6)
  3187.         bra  first_cylinder
  3188.  
  3189. last_cylinder:
  3190.         move.l c4_adress,flash_adress
  3191.         move.b #$01,color_ptr
  3192.         bsr  wait_key
  3193.         cmpi.b #$4f,d0
  3194.         beq.s  lc_down
  3195.         cmpi.b #$4e,d0
  3196.         beq.s  lc_up
  3197.         cmpi.b #$43,d0
  3198.         beq  compare_lc
  3199.         cmpi.b #$44,d0
  3200.         bne.s  last_cylinder
  3201. compare_lc:
  3202.         move.b fc,d0
  3203.         cmp.b lc,d0
  3204.         beq  compare_lc2
  3205.         bge.s  last_cylinder
  3206. compare_lc2:
  3207.         move.b #$00,color_ptr
  3208.         bra  menu_control
  3209. lc_down:subi.b #$01,lc
  3210.         cmpi.b #$ff,lc
  3211.         bne.s  lc_down2
  3212.         move.b #$00,lc
  3213. lc_down2:
  3214.         bra  lcc
  3215. lc_up:  addi.b #$01,lc
  3216.         cmpi.b #$52,lc
  3217.         bne.s  lc_down2
  3218.         move.b #$51,lc
  3219. lcc:    bsr.s  show_lc
  3220.         bra  last_cylinder
  3221. show_lc:lea    lc_text,a0
  3222.         move.b lc,d0
  3223.         bsr  byte_calculate
  3224.         move.l gfxbase,a6
  3225.         lea    rastport,a1
  3226.         move.w #295,d0
  3227.         move.w #74,d1
  3228.         jsr    Movee(a6)
  3229.         lea    rastport,a1
  3230.         lea    lc_text,a0
  3231.         move.w #$0002,d0
  3232.         jsr    Textout(a6)
  3233.         rts
  3234.  
  3235. how_many_tries:
  3236.         move.l c5_adress,flash_adress
  3237.         move.b #$01,color_ptr
  3238. tries1: lea    tr_text,a0
  3239.         bsr  wait_key
  3240.         cmpi.b #$4e,d0
  3241.         beq.s  tries_up
  3242.         cmpi.b #$4f,d0
  3243.         beq.s  tries_down
  3244.         cmpi.b #$43,d0
  3245.         beq.s  end_tries
  3246.         cmpi.b #$44,d0
  3247.         bne.s  tries1
  3248. end_tries:
  3249.         move.b #$00,color_ptr
  3250.         bra  menu_control
  3251. tries_up:
  3252.         addi.b #$01,tr
  3253.         cmpi.b #$0a,tr
  3254.         bne.s  tries_up2
  3255.         move.b #$09,tr
  3256. tries_up2:
  3257.         move.b tr,d0
  3258.         addi.w #$30,d0
  3259.         move.b d0,(a0)
  3260.         bra.s  tries2
  3261. tries_down:
  3262.         subi.b #$01,tr
  3263.         cmpi.b #$00,tr
  3264.         bne.s  tries_down2
  3265.         move.b #$01,tr
  3266. tries_down2:
  3267.         move.b tr,d0
  3268.         addi.w #$30,d0
  3269.         move.b d0,(a0)
  3270. tries2: move.l gfxbase,a6
  3271.         lea    rastport,a1
  3272.         move.w #303,d0
  3273.         move.w #84,d1
  3274.         jsr    Movee(a6)
  3275.         lea    rastport,a1
  3276.         lea    tr_text,a0
  3277.         move.w #$0001,d0
  3278.         jsr    Textout(a6)
  3279.         bra  tries1
  3280.  
  3281. synccorrection:
  3282.         move.l c12_adress,flash_adress
  3283.         move.b #$01,color_ptr
  3284.         cmpi.b #$01,sy
  3285.         bne.s  sync2
  3286.         clr.b  sy
  3287.         lea    off_text,a0
  3288.         bra.s  sync3
  3289. sync2:  move.b #$01,sy
  3290.         lea    on_text,a0
  3291. sync3:  lea    rastport,a1
  3292.         move.w #287,d0
  3293.         move.w #157,d1
  3294.         jsr    Movee(a6)
  3295.         lea    rastport,a1
  3296.         move.w #3,d0
  3297.         jsr    Textout(a6)
  3298.         move.b #$00,color_ptr
  3299.         bra  menu_control
  3300.  
  3301. write_serveral_times:
  3302.         move.l c6_adress,flash_adress
  3303.         move.b #$01,color_ptr
  3304.         move.b sd,d0
  3305.         cmp.b dd,d0
  3306.         bne  wait_return
  3307.         cmpi.b #$00,ws
  3308.         bne.s  write_s2
  3309. write_s1:
  3310.         move.b #$01,ws
  3311.         lea    on_text,a0
  3312.         bra.s  end_write_serveral
  3313. write_s2:
  3314.         move.b #$00,ws
  3315.         lea    off_text,a0
  3316. end_write_serveral:
  3317.         move.l gfxbase,a6
  3318.         lea    rastport,a1
  3319.         move.w #287,d0
  3320.         move.w #94,d1
  3321.         jsr    Movee(a6)
  3322.         lea    rastport,a1
  3323.         move.w #$0003,d0
  3324.         jsr    Textout(a6)
  3325. esw:    move.b #$00,color_ptr
  3326.         bra  menu_control
  3327.  
  3328. verify_destination:
  3329.         move.b dc1,d0
  3330.         or.b dc2,d0
  3331.         tst.b d0
  3332.         bne menu_control
  3333.         move.l c7_adress,flash_adress
  3334.         move.b #$01,color_ptr
  3335.         cmpi.b #$00,vd
  3336.         bne.s  verify_d2
  3337. verify_d1:
  3338.         move.b #$01,vd
  3339.         lea    on_text,a0
  3340.         bra.s  end_verify
  3341. verify_d2:
  3342.         move.b #$00,vd
  3343.         lea    off_text,a0
  3344. end_verify:
  3345.         bsr verify_d3
  3346.         bra  menu_control
  3347. verify_off:
  3348.         move.b #$00,vd
  3349.         lea    off_text,a0
  3350. verify_d3:
  3351.         move.l gfxbase,a6
  3352.         lea    rastport,a1
  3353.         move.w #287,d0
  3354.         move.w #104,d1
  3355.         jsr    Movee(a6)
  3356.         lea    rastport,a1
  3357.         move.w #$0003,d0
  3358.         jsr    Textout(a6)
  3359.         move.b #$00,color_ptr
  3360.         rts
  3361.  
  3362. fast_copy:
  3363.         move.l c8_adress,flash_adress
  3364.         move.b #$01,color_ptr
  3365.         cmpi.b #$01,dd
  3366.         beq.s  fcop1
  3367.         cmpi.b #$02,dd
  3368.         beq.s  fcop1
  3369.         cmpi.b #$04,dd
  3370.         beq.s  fcop1
  3371.         cmpi.b #$08,dd
  3372.         beq.s  fcop1
  3373.         bra  wait_return
  3374. fcop1:  cmpi.b #$01,fa
  3375.         bne.s  fastcopy1
  3376.         move.b #$00,fa
  3377.         move.b #$01,dc1
  3378.         move.b #$00,dc2
  3379.         bra.s  end_fast
  3380. fastcopy1:
  3381.         move.b #$01,fa
  3382.         move.b #$00,dc1
  3383.         move.b #$00,dc2
  3384. end_fast:
  3385.         cmp.b #ON,DC1
  3386.         bne fcop2
  3387.         bsr verify_off
  3388. fcop2:  bsr  show_copies
  3389.         move.b #$00,color_ptr
  3390.         bra  menu_control
  3391.  
  3392. deepcopy_1:
  3393.         bsr verify_off
  3394.         move.l c9_adress,flash_adress
  3395.         move.b #$01,color_ptr
  3396.         cmpi.b #$01,dd
  3397.         beq.s  deep4
  3398.         cmpi.b #$02,dd
  3399.         beq.s  deep4
  3400.         cmpi.b #$04,dd
  3401.         beq.s  deep4
  3402.         cmpi.b #$08,dd
  3403.         beq.s  deep4
  3404.         bra.s  wait_return
  3405. deep4:  cmpi.b #$00,dc1
  3406.         beq.s  deep1
  3407.         move.b #$00,fa
  3408.         move.b #$00,dc1
  3409.         move.b #$01,dc2
  3410.         bra.s  end_deep1
  3411. deep1:  move.b #$00,fa
  3412.         move.b #$01,dc1
  3413.         move.b #$00,dc2
  3414. end_deep1:
  3415.         bra  end_fast
  3416.  
  3417. wait_return:
  3418.         move.l #text12,text_ptr
  3419.         move.w #16,x1
  3420.         move.w #28,y1
  3421.         bsr    set_text3
  3422. wait_r3:bsr    wait_key
  3423.         cmpi.b #$44,d0
  3424.         beq.s  wait_r2
  3425.         cmpi.b #$43,d0
  3426.         bne.s  wait_return
  3427. wait_r2:
  3428.         bsr    BegText
  3429.         bra    end_fast
  3430. wait_r4:bsr    wait_key
  3431.         cmpi.b #$45,d0
  3432.         beq.s  wait_r5
  3433.         cmpi.b #$44,d0
  3434.         beq    \W1
  3435.         cmpi.b #$43,d0
  3436.         beq    \W1
  3437.         cmpi.b #$40,d0
  3438.         bne.s  wait_r4
  3439. \W1:    move.l d0,-(a7)
  3440.         bsr    clear_eol
  3441.         move.l (a7)+,d0
  3442.         clr.l  d0
  3443.         rts
  3444. wait_r5:move.l #-1,d0
  3445.         move.w #Escape,ErrorFlag
  3446.         rts
  3447.  
  3448. deepcopy_2:
  3449.         bsr    verify_off
  3450.         move.l c10_adress,flash_adress
  3451.         move.b #$01,color_ptr
  3452.         cmpi.b #$01,dd
  3453.         beq.s  deep3
  3454.         cmpi.b #$02,dd
  3455.         beq.s  deep3
  3456.         cmpi.b #$04,dd
  3457.         beq.s  deep3
  3458.         cmpi.b #$08,dd
  3459.         beq.s  deep3
  3460.         bra    wait_return
  3461. deep3:  cmpi.b #$01,dc2
  3462.         beq.s  deep2
  3463.         move.b #$00,fa
  3464.         move.b #$00,dc1
  3465.         move.b #$01,dc2
  3466.         bra.s  end_deep2
  3467. deep2:  move.b #$01,fa
  3468.         move.b #$00,dc1
  3469.         move.b #$00,dc2
  3470. end_deep2:
  3471.         bra    end_fast
  3472. show_copies:
  3473.         move.l gfxbase,a6
  3474.         lea    rastport,a1
  3475.         move.w #287,d0
  3476.         move.w #114,d1
  3477.         jsr    Movee(a6)
  3478.         lea    rastport,a1
  3479.         cmpi.b #$00,fa
  3480.         beq.s  show1
  3481.         lea    on_text,a0
  3482.         bra.s  show2
  3483. show1:  lea    off_text,a0
  3484. show2:  move.w #$0003,d0
  3485.         jsr    Textout(a6)
  3486.         lea    rastport,a1
  3487.         move.w #287,d0
  3488.         move.w #124,d1
  3489.         jsr    Movee(a6)
  3490.         lea    rastport,a1
  3491.         cmpi.b #$00,dc1
  3492.         beq.s  show3
  3493.         lea    on_text,a0
  3494.         bra.s  show4
  3495. show3:  lea    off_text,a0
  3496. show4:  move.w #$0003,d0
  3497.         jsr    Textout(a6)
  3498.         lea    rastport,a1
  3499.         move.w #287,d0
  3500.         move.w #134,d1
  3501.         jsr    Movee(a6)
  3502.         lea    rastport,a1
  3503.         cmpi.b #$00,dc2
  3504.         beq.s  show5
  3505.         lea    on_text,a0
  3506.         bra.s  show6
  3507. show5:  lea    off_text,a0
  3508. show6:  move.w #$0003,d0
  3509.         jsr    Textout(a6)
  3510.         rts
  3511.  
  3512. source_drive:
  3513.         move.l c11_adress,flash_adress
  3514.         move.b #$01,color_ptr
  3515. source1:
  3516.         bsr    wait_key
  3517.         cmpi.b #$0a,d0
  3518.         beq.s  s_drive0
  3519.         cmpi.b #$01,d0
  3520.         beq.s  s_drive1
  3521.         cmpi.b #$02,d0
  3522.         beq    s_drive2
  3523.         cmpi.b #$03,d0
  3524.         beq    s_drive3
  3525.         cmpi.b #$43,d0
  3526.         beq.s  source2
  3527.         cmpi.b #$44,d0
  3528.         bne.s  source1
  3529. source2:move.b pointer1,d7
  3530.         clr.b  pointer1
  3531.         bsr    end_drive
  3532.         move.b d7,pointer1
  3533.         move.b #$00,color_ptr
  3534.         bra    menu_control
  3535. s_drive0:
  3536.         btst   #$00,drives
  3537.         beq    source1
  3538. s_dd0:  move.b #$01,sd
  3539.         move.b #$00,d0
  3540.         bra    set_s_drive
  3541. s_drive1:
  3542.         btst   #$01,drives
  3543.         beq    source1
  3544. s_dd1:  move.b #$02,sd
  3545.         move.b #$01,d0
  3546.         bra    set_s_drive
  3547. s_drive2:
  3548.         btst   #$02,drives
  3549.         beq    source1
  3550. s_dd2:  move.b #$04,sd
  3551.         move.b #$02,d0
  3552.         bra.s  set_s_drive
  3553. s_drive3:
  3554.         btst   #$03,drives
  3555.         beq    source1
  3556.         move.b #$08,sd
  3557. s_dd3:  move.b #$03,d0
  3558. set_s_drive:
  3559.         lea    sd_text,a0
  3560.         addi.b #$30,d0
  3561.         move.b d0,(a0)
  3562.         move.l gfxbase,a6
  3563.         lea    rastport,a1
  3564.         move.w #303,d0
  3565.         move.w #144,d1
  3566.         jsr    movee(a6)
  3567.         lea    rastport,a1
  3568.         move.w #$0001,d0
  3569.         jsr    Textout(a6)
  3570.         bra    source1
  3571.  
  3572. byte_calculate:
  3573.         cmpi.w #$0a,d0
  3574.         bmi.s  byte2
  3575.         divu   #$0a,d0
  3576.         move.w d0,d1
  3577.         addi.w #$30,d1
  3578.         swap   d0
  3579.         bra.s  byte3
  3580. byte2:  move.w #$0030,d1
  3581. byte3:  move.b d1,(a0)+
  3582.         addi.w #$0030,d0
  3583.         move.b d0,(a0)+
  3584.         rts
  3585.  
  3586. adresses:
  3587.         move.l cop_adress,d0
  3588.         move.l #color1,d1
  3589.         move.l #ncopper,d2
  3590.         sub.l  d2,d1
  3591.         add.l  d1,d0
  3592.         move.l d0,c1_adress
  3593.         addi.l #$000010,d0
  3594.         move.l d0,c2_adress
  3595.         addi.l #$000008,d0
  3596.         move.l d0,c3_adress
  3597.         addi.l #$000008,d0
  3598.         move.l d0,c4_adress
  3599.         addi.l #$000008,d0
  3600.         move.l d0,c5_adress
  3601.         addi.l #$000008,d0
  3602.         move.l d0,c6_adress
  3603.         addi.l #$000008,d0
  3604.         move.l d0,c7_adress
  3605.         addi.l #$000008,d0
  3606.         move.l d0,c8_adress
  3607.         addi.l #$000008,d0
  3608.         move.l d0,c9_adress
  3609.         addi.l #$000008,d0
  3610.         move.l d0,c10_adress
  3611.         addi.l #$000008,d0
  3612.         move.l d0,c11_adress
  3613.         addi.l #$000008,d0
  3614.         move.l d0,c12_adress
  3615.         addi.l #$000010,d0
  3616.         move.l d0,c13_adress
  3617.         rts
  3618.  
  3619. set_title:
  3620.         clr.l  d6
  3621.         move.w #$0009,d6
  3622. set_text1:
  3623.         move.l gfxbase,a6
  3624.         bsr    set_text2
  3625.         addi.l #$000026,text_ptr
  3626.         addi.w #$000a,y1
  3627.         dbf    d6,set_text1
  3628.         lea    floppy,a0
  3629.         move.l bit_adress,a1
  3630.         add.l  #$001c26,a1
  3631.         move.l a1,a2
  3632.         bsr.s  box
  3633.         lea    floppy,a0
  3634.         move.l a1,a2
  3635.         add.l  #$000008,a2
  3636.         bsr.s  box
  3637.         lea    floppy,a0
  3638.         move.l a1,a2
  3639.         add.l  #$000010,a2
  3640.         bsr.s  box
  3641.         lea    floppy,a0
  3642.         move.l a1,a2
  3643.         add.l  #$000018,a2
  3644.         bsr.s  box
  3645.         bra.s  set_work
  3646. box:    rts                    ;Remove this rts for PAL systems
  3647.         move.w #floppy_s,d0    ;will draw graphic disk drive onscreen
  3648. bit_copy_loop:
  3649.         move.b (a0)+,(a2)+
  3650.         move.b (a0)+,(a2)+
  3651.         move.b (a0)+,(a2)+
  3652.         move.b (a0)+,(a2)+
  3653.         move.b (a0)+,(a2)+
  3654.         move.b (a0)+,(a2)+
  3655.         add.l  #$22,a2
  3656.         dbf    d0,bit_copy_loop
  3657.         rts
  3658. set_work:
  3659.         move.w #44,y2
  3660.         bsr    draw_line
  3661.         move.w #148,y2
  3662.         bsr    draw_line
  3663.         move.w #218,y2
  3664.         bsr    draw_line
  3665.         move.w #250,y2
  3666.         bsr    draw_line
  3667.         move.w #160,y2
  3668.         bsr    draw_line
  3669.         move.w #157,y1
  3670.         move.l #text11,text_ptr
  3671.         bsr    set_text2
  3672.         move.w #170,y1
  3673.         move.w #$0001,d2
  3674.         move.l #text2,text_ptr
  3675. set_loop2:
  3676.         bsr    set_text2
  3677.         addi.l #$000026,text_ptr
  3678.         addi.w #$000a,y1
  3679.         dbf    d2,set_loop2
  3680.         move.w #$0001,d2
  3681.         move.l #text3,text_ptr
  3682.         move.w #200,y1          ;PAL uses 230
  3683.  
  3684.         bsr    set_text2;         ;added to NTSC
  3685.         move.l #text3a,text_ptr ;added to NTSC
  3686.         move.w #7,x1            ;to position text
  3687.         move.w #210,y1          ;PAL uses 245
  3688.  
  3689.  
  3690. set_loop3:
  3691.         bsr    set_text2
  3692.         addi.w #$000f,y1
  3693.         addi.l #$000026,text_ptr
  3694.         dbf    d2,set_loop3
  3695.         lea    rastport,a1
  3696.         move.b #1,d0
  3697.         jsr    SetAPen(a6)
  3698.         lea    rastport,a1
  3699.         move.w #10,d0
  3700.         move.w #10,d1
  3701.         move.w #309,d2
  3702.         move.w #40,d3
  3703.         jsr    RectFill(a6)
  3704.         lea    rastport,a1
  3705.         move.b #0,d0
  3706.         jsr    SetAPen(a6)
  3707.         lea    rastport,a1
  3708.         move.w #11,d0
  3709.         move.w #11,d1
  3710.         move.w #308,d2
  3711.         move.w #39,d3
  3712.         jsr    RectFill(a6)
  3713.         lea    rastport,a1
  3714.         move.b #1,d0
  3715.         jsr    SetAPen(a6)
  3716. BegText: move.l #text4,text_ptr
  3717.         move.w #16,x1
  3718.         move.w #18,y1
  3719.         bsr    set_text3
  3720.         move.l #text20,text_ptr
  3721.         move.w #28,y1
  3722.         bsr    set_text3
  3723.         move.l #text21,text_ptr
  3724.         move.w #38,y1
  3725.         bsr    set_text3
  3726.         rts
  3727.  
  3728. draw_line:
  3729.         lea    rastport,a1
  3730.         move.w #$0000,d0
  3731.         move.w y2,d1
  3732.         jsr    Movee(a6)
  3733.         lea    rastport,a1
  3734.         move.w #$013f,d0
  3735.         move.w y2,d1
  3736.         jsr    Draw(a6)
  3737.         rts
  3738.  
  3739. set_text2:
  3740.         move.l a6,-(a7)
  3741.         move.l gfxbase,a6
  3742.         lea    rastport,a1
  3743.         move.w x1,d0
  3744.         move.w y1,d1
  3745.         jsr    Movee(a6)
  3746.         lea    rastport,a1
  3747.         move.l text_ptr,a0
  3748.         move.w #$0026,d0
  3749.         jsr    Textout(a6)
  3750.         move.l (a7)+,a6
  3751.         rts
  3752.  
  3753. set_text3:
  3754.         move.l a6,-(a7)
  3755.         move.l gfxbase,a6
  3756.         lea    rastport,a1
  3757.         move.w x1,d0
  3758.         move.w y1,d1
  3759.         jsr    Movee(a6)
  3760.         lea    rastport,a1
  3761.         move.l text_ptr,a0
  3762.         move.w #$0024,d0
  3763.         jsr    Textout(a6)
  3764.         move.l (a7)+,a6
  3765.         rts
  3766.  
  3767. show_start:
  3768.         lea    text6,a0
  3769.         btst   #0,dd
  3770.         bne    show_s1
  3771.         btst   #0,sd
  3772.         beq.s  show_start1
  3773. show_s1:lea    df0,a1
  3774.         bsr    copy_drives
  3775. show_start1:
  3776.         btst   #1,dd
  3777.         bne.s  show_s2
  3778.         btst   #1,sd
  3779.         beq.s  show_start2
  3780. show_s2:lea    df1,a1
  3781.         bsr    copy_drives
  3782. show_start2:
  3783.         btst   #2,dd
  3784.         bne.s  show_s3
  3785.         btst   #2,sd
  3786.         beq.s  show_start3
  3787. show_s3:lea    df2,a1
  3788.         bsr.s  copy_drives
  3789. show_start3:
  3790.         btst   #3,dd
  3791.         bne.s  show_s4
  3792.         btst   #3,sd
  3793.         beq.s  show_start4
  3794. show_s4:lea    df3,a1
  3795.         bsr.s  copy_drives
  3796. show_start4:
  3797.         move.w #16,x1
  3798.         move.w #18,y1
  3799.         move.w #$002,d2
  3800.         move.l #text5,text_ptr
  3801. show_loop:
  3802.         bsr    set_text3
  3803.         addi.w #$000a,y1
  3804.         addi.l #$000024,text_ptr
  3805.         dbf    d2,show_loop
  3806.         move.w #16,d0
  3807.         lea    text6,a0
  3808. lop:    move.b #$20,(a0)+
  3809.         dbf    d0,lop
  3810.         rts
  3811.  
  3812. copy_drives:
  3813.         move.w #$0003,d0
  3814. copy_d_loop:
  3815.         move.b (a1)+,(a0)+
  3816.         dbf    d0,copy_d_loop
  3817.         rts
  3818.  
  3819. read_error:
  3820.         clr.l  d0
  3821.         move.b cylinder,d0
  3822.         lea    text7,a0
  3823.         add.l  #$00001a,a0
  3824.         bsr    byte_calculate
  3825.         move.b side,d0
  3826.         add.l  #$000006,a0
  3827.         bsr    byte_calculate
  3828.         move.w #7,x1
  3829.         move.w #200,y1         ;PAL uses 230
  3830.         move.l #text7,text_ptr
  3831.         bra    set_text2
  3832.  
  3833. write_error:
  3834.         clr.l  d0
  3835.         move.b cylinder,d0
  3836.         lea    text8,a0
  3837.         add.l  #$00001b,a0
  3838.         bsr    byte_calculate
  3839.         move.b side,d0
  3840.         add.l  #$000006,a0
  3841.         bsr    byte_calculate
  3842.         move.w #7,x1
  3843.         move.w #200,y1         ;PAL uses 230
  3844.         move.l #text8,text_ptr
  3845.         bra    set_text2
  3846.  
  3847. clear_error:
  3848.         move.l #text3,text_ptr
  3849.         move.w #7,x1
  3850.         move.w #200,y1      ;PAL uses 230
  3851.         bra    set_text2
  3852.  
  3853.         move.l #text3a,text_ptr ;added to NTSC
  3854.         move.w #7,x1            ;to position text
  3855.         move.w #210,y1          ;(PAL uses 245)
  3856.         bra    set_text2          ;on the screen
  3857.  
  3858.  
  3859. reading_cyl:
  3860.         clr.l  d0
  3861.         move.b cylinder,d0
  3862.         lea    rcyl_text,a0
  3863.         bsr    byte_calculate
  3864.         lea    rcyl_text,a0
  3865.         move.l gfxbase,a6
  3866.         lea    rastport,a1
  3867.         move.w #127,d0
  3868.         move.w #210,d1         ;PALS uses 245
  3869.         jsr    Movee(a6)
  3870.         lea    rastport,a1
  3871.         move.w #$0002,d0
  3872.         jsr    Textout(a6)
  3873.         rts
  3874. writing_cyl:
  3875.         clr.l  d0
  3876.         move.b cylinder,d0
  3877.         lea    wcyl_text,a0
  3878.         bsr    byte_calculate
  3879.         lea    wcyl_text,a0
  3880.         move.l gfxbase,a6
  3881.         lea    rastport,a1
  3882.         move.w #271,d0
  3883.         move.w #210,d1         ;PAL uses 245
  3884.         jsr    Movee(a6)
  3885.         lea    rastport,a1
  3886.         move.w #$0002,d0
  3887.         jsr    Textout(a6)
  3888.         rts
  3889.  
  3890. insert_source:
  3891.         move.l #text9,text_ptr
  3892.         bra.s  melvin
  3893. insert_destination:
  3894.         move.l #text10,text_ptr
  3895.         bra.s  melvin
  3896. protect_source:
  3897.         bsr  cl
  3898.         move.l #text13,text_ptr
  3899.         bra.s  melvin
  3900. protect_destination:
  3901.         bsr  cl
  3902.         move.l #text14,text_ptr
  3903. melvin:
  3904.         move.w #16,x1
  3905.         move.w #28,y1
  3906.         bsr    set_text3
  3907.         move.l #text5,text_ptr
  3908.         move.w #18,y1
  3909.         bsr    set_text3
  3910.         bra    wait_r4
  3911. clear_eol:
  3912.         move.l #text15,text_ptr
  3913.         move.w #16,x1
  3914.         move.w #28,y1
  3915.         bsr    set_text3
  3916.         move.w #18,y1
  3917.         bra    set_text3
  3918.  
  3919. write_b_again:
  3920.         bsr  cl
  3921.         move.l #text17,text_ptr
  3922.         move.w #16,x1
  3923.         move.w #28,y1
  3924.         bsr    set_text3
  3925. wba1:   bsr    wait_key
  3926.         cmpi.b #$45,d0   ;check esc
  3927.         beq.s  wba4
  3928.         cmpi.b #$15,d0   ;German keyboards use 31 y and z reversed
  3929.         beq.s  wba2
  3930.         cmpi.b #$36,d0   ;check n
  3931.         bne.s  wba1
  3932.         move.l #-1,d0
  3933.         bra.s  wba3
  3934. wba2:   clr.l  d0
  3935. wba3:   move.l d0,-(a7)
  3936.         bsr    clear_eol
  3937.         move.l (a7)+,d0
  3938.         rts
  3939. wba4:   move.w #escape,errorflag
  3940.         rts
  3941.  
  3942. compare_drives:
  3943.         move.w #18,y1
  3944.         bsr    cl2
  3945.         lea    text19,a0
  3946.         clr.w  d2
  3947. cdl1:   lea    df0,a1
  3948.         btst   d2,vererrflag
  3949.         beq.s  cdl4
  3950.         move.w d2,d0
  3951.         lsl    #2,d0
  3952.         add.l  d0,a1
  3953.         bsr.s  cdl2
  3954. cdl4:   addq.w #1,d2
  3955.         cmpi.w #4,d2
  3956.         bne.s  cdl1
  3957.         move.l #text18,text_ptr
  3958.         move.w #28,y1
  3959.         bra    set_text3
  3960. cdl2:   move.w #3,d1
  3961. cdl3:   move.b (a1)+,(a0)+
  3962.         dbf    d1,cdl3
  3963.         rts
  3964.  
  3965. wait_key:
  3966.         movem.l d1-d7,-(a7)
  3967.         move.w Keybrdclr,d1
  3968. l8:     move.b IntCon,d0
  3969.         btst   #7,d1
  3970.         bne    l1
  3971.         sub.l  #1,Keybrdcnt
  3972.         beq    Keybrepeat
  3973. l1:     btst   #3,d0
  3974.         beq    l8
  3975.         move.b Key,d0
  3976.         ori.b  #$40,Cont
  3977.         not.b  d0
  3978.         ror.b  #1,d0
  3979.         move.w #$600,d1
  3980. l5:     dbf    d1,l5
  3981.         andi.b #$bf,Cont
  3982.         move.l #MaxWait,Cntwait
  3983.         move.l #MaxWait,Keybrdcnt
  3984.         move.w d0,Keybrdclr
  3985. Keybtdend:
  3986.         movem.l (a7)+,d1-d7
  3987.         rts
  3988. Keybrepeat:
  3989.         move.l Cntwait,d1
  3990.         cmp.l  #MinWait,d1
  3991.         bcs.s  repeat1
  3992.         sub.l  #$800,d1
  3993.         move.l d1,Cntwait
  3994. repeat1:move.l d1,Keybrdcnt
  3995.         move.w Keybrdclr,d0
  3996.         bra.s  Keybtdend
  3997.  
  3998. get_key:
  3999.         move.w $dff01e,d1
  4000.         btst   #3,d1
  4001.         beq    \l1
  4002.         move.b Key,d0
  4003.         ori.b  #$40,Cont
  4004.         not.b  d0
  4005.         ror.b  #1,d0
  4006.         move.w #$600,d1
  4007. \l2:    dbf    d1,\l2
  4008.         andi.b #$bf,Cont
  4009. \l1:    rts
  4010.  
  4011. cl:     move.w #28,y1
  4012. cl2:    move.w #16,x1
  4013.         move.l #text15,text_ptr
  4014.         bsr    set_text3
  4015.         addi.w #10,y1
  4016.         bsr    set_text3
  4017.         rts
  4018.  
  4019. cl1:    bsr.s  cl
  4020.         move.w #18,y1
  4021.         bsr    set_text3
  4022.         move.w #28,y1
  4023.         move.l #text16,text_ptr
  4024.         bsr    set_text3
  4025.         rts
  4026.  
  4027.  
  4028. gfxname:
  4029.          dc.b "graphics.library",0
  4030.          align.w
  4031. gfxbase:        dc.l 0
  4032. oldcopper:      dc.l 0
  4033. bit_adress:     dc.l 0
  4034. cop_adress:     dc.l 0
  4035. c1_adress:      dc.l 0
  4036. c2_adress:      dc.l 0
  4037. c3_adress:      dc.l 0
  4038. c4_adress:      dc.l 0
  4039. c5_adress:      dc.l 0
  4040. c6_adress:      dc.l 0
  4041. c7_adress:      dc.l 0
  4042. c8_adress:      dc.l 0
  4043. c9_adress:      dc.l 0
  4044. c10_adress:     dc.l 0
  4045. c11_adress:     dc.l 0
  4046. c12_adress:     dc.l 0
  4047. c13_adress:     dc.l 0
  4048.  
  4049. rastport:       blk.l  1,0
  4050. r_bitmap:       blk.l 24,0
  4051.  
  4052. bitmap:         blk.l  2,0
  4053. plane1:         blk.l  8,0
  4054.  
  4055. ncopper:
  4056.                 dc.w $008e,$2681,$0090,$24c1
  4057.                 dc.w $0092,$0038,$0094,$00d0
  4058.                 dc.w $00e0
  4059. plane_hi:       dc.w $0000,$00e2
  4060. plane_lo:       dc.w $0000
  4061.                 dc.w $0100,$1200,$0102,$0000,$0104,$0000
  4062.                 dc.w $0108,$0000,$010a,$0000
  4063.                 dc.w $0120,$0000,$0122,$0000
  4064.                 dc.w $0180,$0000,$0182
  4065. color1:         dc.w $00ee,$0d01,$fffe,$0182
  4066.                 dc.w $00ee,$5401,$fffe,$0182
  4067. color2:         dc.w $00ee,$6001,$fffe,$0182
  4068. color3:         dc.w $00ee,$6a01,$fffe,$0182
  4069. color4:         dc.w $00ee,$7201,$fffe,$0182
  4070. color5:         dc.w $00ee,$7d01,$fffe,$0182
  4071. color6:         dc.w $00ee,$8601,$fffe,$0182
  4072. color7:         dc.w $00ee,$9001,$fffe,$0182
  4073. color8:         dc.w $00ee,$9a01,$fffe,$0182
  4074. color9:         dc.w $00ee,$a401,$fffe,$0182
  4075. color10:        dc.w $00ee,$af01,$fffe,$0182
  4076. color11:        dc.w $00ee,$b701,$fffe,$0182
  4077. color12:        dc.w $00ee,$c501,$fffe,$0182
  4078.                 dc.w $00ee,$c701,$fffe,$0182
  4079. color13:        dc.w $00ee,$ff01,$fffe,$0182
  4080.                 dc.w $00ee,$ffff,$fffe
  4081.                 dc.w $0000,$0000
  4082. copend:
  4083. copsize = copend - ncopper
  4084.  
  4085. drives:         dc.b 0
  4086. d_drives:       dc.b 0
  4087. s_drives:       dc.b 0
  4088. color_ptr:      dc.b 0
  4089. back:           dc.b 0
  4090. pointer1:       dc.b 0
  4091. cylinder:       dc.b 0
  4092. side:           dc.b 0
  4093. new:            dc.b 0
  4094. drv:            dc.b 0
  4095.        align.w
  4096. flash_adress:   dc.l 0
  4097. text_ptr:       dc.l 0
  4098.  
  4099. x1:             dc.w 7
  4100. y1:             dc.w 54
  4101. y2:             dc.w 0
  4102.  
  4103. keybrdclr:      dc.w $ffff
  4104. cntwait:        dc.l MaxWait
  4105. keybrdcnt:      dc.l MaxWait
  4106.  
  4107. fc_text:        dc.b "00"
  4108. ralf:           dc.b 0
  4109. lc_text:        dc.b "79"
  4110. tr_text:        dc.b "0"
  4111. sd_text:        dc.b "0"
  4112. rcyl_text:      dc.b "00"
  4113. wcyl_text:      dc.b "00"
  4114. on_text:        dc.b ".ON"
  4115. on_text2:       dc.b " ON"
  4116. off_text:       dc.b "OFF"
  4117. df0:            dc.b "DF0 "
  4118. df1:            dc.b "DF1 "
  4119. df2:            dc.b "DF2 "
  4120. df3:            dc.b "DF3 "
  4121.  
  4122. text1:  dc.b "F1  = START COPY......................"
  4123.         dc.b "F2  = FIRST CYLINDER (CRSR).........00"
  4124.         dc.b "F3  = LAST  CYLINDER (CRSR).........79"
  4125.         dc.b "F4  = HOW MANY TRIES (CRSR)..........3"
  4126.         dc.b "F5  = WRITE SEVERAL TIMES..........OFF"
  4127.         dc.b "F6  = VERIFY DESTINATION............ON"
  4128.         dc.b "F7  = FASTCOPY......................ON"
  4129.         dc.b "F8  = DEEPCOPY 1...................OFF"
  4130.         dc.b "F9  = DEEPCOPY 2...................OFF"
  4131.         dc.b "F10 = SOURCE DRIVE (0/1/2/3).......DF0"
  4132. text2:  dc.b "DEL = DESTINATION DRIVE (0/1/2/3)....."
  4133.         dc.b "      DF0:    DF1:    DF2:    DF3:    "
  4134. text3:  dc.b "         STATUS: 00, OK,00,00         "
  4135. text3a: dc.b "  READING CYL. 00 / WRITING CYL. 00   "
  4136. ;text3a added for text positioning on NTSC systems
  4137. text4:  dc.b "       A M I G A - COPY  V1.2       "
  4138. text5:  dc.b "        (ESC) TERMINATES COPY       "
  4139.         dc.b "INSERT DISK(S) IN  "
  4140. text6:  dc.b "                 "
  4141.         dc.b "PRESS RETURN OR ENTER WHEN READY !¡!"
  4142. text7:  dc.b "STATUS: READ-ERROR ON CYL.00 SIDE 00  "
  4143. text8:  dc.b "STATUS: WRITE-ERROR ON CYL.00 SIDE 00 "
  4144. text9:  dc.b "    PLEASE INSERT SOURCE DISK !!    "
  4145. text10: dc.b "  PLEASE INSERT DESTINATION DISK !  "
  4146. text11: dc.b " S  = SYNC-CORRECTION...  ..........ON"
  4147. text12: dc.b "       ONLY ONE DESTINATION !!      "
  4148. text13: dc.b " SOURCE DISK INSN'T WRITE PROTECTED."
  4149. text14: dc.b "DESTINATION DISK IS WRITE PROTECTED."
  4150. text15: dc.b "                                    "
  4151. text16: dc.b "          COPY COMPLETE !!          "
  4152. text17: dc.b "    WRITE BUFFER AGAIN ??? (Y/N)    "
  4153. text18: dc.b " ERROR ON DRIVE(S) "
  4154. text19: dc.b "                 "
  4155. text20: dc.b "            WRITTEN BY :            "
  4156. text21: dc.b "   R. GELFAND AND S. THUBEAUVILLE   "
  4157.        align.w
  4158. floppy:
  4159.  dc.l $00000000,$00000000,$00000000,$00000000,$000007ff,$ffffffe0
  4160.  dc.l $04000000,$002005ff,$ffffffa0,$05ffffff,$ffa00400,$00000020
  4161.  dc.l $04ffffff,$ff200880,$00000110,$08800000,$01100880,$1ff80110
  4162.  dc.l $08801008,$011008bf,$f00ffd10,$07a00000,$05e008bf,$f00ffd10
  4163.  dc.l $08800ff0,$01100a90,$00000110,$08800000,$01100480,$00000120
  4164.  dc.l $04ffffff,$ff200400,$00000020,$07ffffff,$ffe00000,$00000000
  4165. floppyend:
  4166. ;graphic of disk drive not used by NTSC system
  4167.  
  4168. ;Fast Copy
  4169.  
  4170. DecodeCnt:     dc.w 0      ;Counter for longwords to be decoded 
  4171. DecodeAdr:     dc.l 0      ;Address where to decode 
  4172. BlockAdr:      dc.w 0      ;Offset in Block for decoding 
  4173. FTestAdr:      dc.l 0      ;Test address if Block already loaded 
  4174. SectNum:       dc.w 0      ;Counter for Sector number
  4175. BytesBefGap:   dc.w 0      ;Bytes before the Gap
  4176. BytesAftGAp:   dc.w 0      ;Bytes after the Gap
  4177. FirstBlock:    dc.w 0      ;Block number of the first Block
  4178. FirstBlockSp:  dc.w 0      ;permanent memory for first Block
  4179. SectBL:        dc.w 0      ;Sector counter for Sectors before the Gap
  4180. VerifyFlag:    dc.w 0      ;indicates if read or Verify
  4181. VerErrFlag:    dc.w 0      ;Flag for Errors 
  4182.                            ;Verify-Bit = 1 => Error
  4183. TNumBufferA:   dc.w 0      ;Track-Number memory 
  4184.                            ;for 1D-Copy (Start-Track)
  4185. TNumBufferE    dc.w 0      ;Buffer for End number 
  4186.                            ;of loaded Tracks
  4187. BlockMessage:  ds.w 11
  4188.  
  4189. ;Cruncher
  4190.  
  4191. Length:         dc.w $1600
  4192. ShrtByte:       dc.b 0
  4193.                align.w
  4194. TrackPointer:   ds.l 164   ;memory for Pointer to packed Tracks
  4195. MemoryBeg:      dc.l 0     ;memory beginning for crunching
  4196. MemoryLength:   dc.l 0     ;memory length for Crunching
  4197. MemoryChip:     dc.l 0
  4198. LengthChip:     dc.l 0
  4199. FreeFlagCh:     dc.w 0
  4200. MemoryFast:     dc.l 0
  4201. LenghtFast:     dc.l 0
  4202. FreeFlagFa:     dc.w 0
  4203. Subtr:          dc.w 0     ;See CrunEnd2
  4204.  
  4205. ;Control 
  4206.  
  4207. TrackBuffer1:  dc.l 0
  4208. TrackBuffer2:  dc.l 0
  4209. TrackNumS:     dc.w 0
  4210. TrackNumD:     dc.w 0
  4211. TrackNum:      dc.w 0
  4212. StartTrack:    dc.w 0      ;first Track to be read
  4213. EndTrack       dc.w 0      ;last Track to be read
  4214. MotorBits:     dc.b $F3
  4215. MotorBitsS:    dc.b $F3
  4216. MotorBitsD:    dc.b $F3
  4217. Flag:          dc.b $00    ;indicates if Source or Dest.
  4218.                align.w
  4219.  
  4220. ;Deep Copy
  4221.  
  4222. Position:      dc.l 0      ;For Search routine
  4223. BitShifts:     dc.w 0      ;number of Bits during shift
  4224. Size1:         dc.w 0      ;size of the largest Block
  4225. Size2:         dc.w 0      ;size of the second largest Block
  4226. SizePos:       dc.l 0      ;Position of the largest Block
  4227. Searchln:      dc.w 0      ;how many defective Words can there be
  4228. NumWords:      dc.w 0      ;how many Words are compared
  4229. ErrorFlag:     dc.w 0
  4230. EndPos:        dc.l 0      ;End position of Track
  4231. BegPos:        dc.l 0      ;beginning of Track (after Gap)
  4232. SLength:       dc.w 0      ;number of Bytes to be written
  4233. WriteAddrs:    dc.l 0      ;Address from which writing starts
  4234. Offset:        dc.w 0      ;number of Bytes before Sync during writing
  4235. TrackBytes:    dc.w 0      ;Bytes on the Track
  4236. CheckLength:   dc.w 0      ;Bytes on the Track (Controll)
  4237. LenghtDest:    dc.w 0      ;Track length of Dest.-Disk
  4238. Syncwidth:     dc.w 0      ;Distance from Index to Sync
  4239. SyncNum:       dc.w 0      ;number of Syncs found
  4240. CopyTry1:      dc.w 0      ;Illegal Data, read how many times
  4241. CopyTry2:      dc.w 0      ;how many times read for NoSync
  4242.  
  4243. Blocks:        ds.l SortBlockNum ;memory for Blocklength+SyncNum
  4244. SortBlocks:    ds.l SortBlockNum ;memory for Block sorting 
  4245. NumSortBlock:  dc.w 0      ;number of different sorted Blocks
  4246.  
  4247. SyncWord:      dc.w $4489  ;Value for reading
  4248.  
  4249. ;Table for Sync-Search 
  4250. ;Sync = $4489
  4251. SyncBase:      dc.l %01000100100010010000000000000000
  4252.                dc.l %00100010010001001000000000000000
  4253.                dc.l %00010001001000100100000000000000
  4254.                dc.l %00001000100100010010000000000000
  4255.                dc.l %00000100010010001001000000000000
  4256.                dc.l %00000010001001000100100000000000
  4257.                dc.l %00000001000100100010010000000000
  4258.                dc.l %00000000100010010001001000000000
  4259.                dc.l %00000000010001001000100100000000
  4260.                dc.l %00000000001000100100010010000000
  4261.                dc.l %00000000000100010010001001000000
  4262.                dc.l %00000000000010001001000100100000
  4263.                dc.l %00000000000001000100100010010000
  4264.                dc.l %00000000000000100010010001001000
  4265.                dc.l %00000000000000010001001000100100
  4266.                dc.l %00000000000000001000100100010010
  4267.                dc.l %00000000000000000100010010001001
  4268.  
  4269. AmigaTrack:    dc.b 0  ;indicates if Amiga-Format on DeepCopy
  4270.  
  4271. fc:  dc.b 00    ;First Cylinder
  4272. lc:  dc.b 79    ;Last    "
  4273. tr:  dc.b 3     ;Tries
  4274. ws:  dc.b 0     ;Write repeatedly 
  4275. vd:  dc.b 1     ;Verify
  4276. fa:  dc.b 1     ;Fast Copy
  4277. dc1: dc.b 0     ;D1 Copy
  4278. dc2: dc.b 0     ;D2 Copy
  4279. sd:  dc.b 1     ;SourceBits
  4280. dd:  dc.b 2     ;DestDits
  4281. sy:  dc.b 0     ;Sync correction 
  4282.  
  4283. waiting: dc.b 0 ;irq wait_conter
  4284.  
  4285. DevName:       dc.b "trackdisk.device",0
  4286.  
  4287.                END
  4288.  
  4289.